length = dst_len;
mutex_lock(&q->mutex);
- l2_table_offset = be64_to_cpu(table->l1_table[l1_idx]) & ~header->oflag_mask;
+
+ l2_table_offset = be64_to_cpu(table->l1_table[l1_idx]);
+ if (l2_table_offset & QCOW_OFLAG_COMPRESSED) {
+ pr_warning("compressed sectors are not supported");
+ goto out_error;
+ }
+
+ l2_table_offset &= QCOW_OFFSET_MASK;
if (!l2_table_offset)
goto zero_cluster;
if (l2_idx >= l2_table_size)
goto out_error;
- clust_start = be64_to_cpu(l2_table->table[l2_idx]) & ~header->oflag_mask;
+ clust_start = be64_to_cpu(l2_table->table[l2_idx]);
+ if (clust_start & QCOW_OFLAG_COMPRESSED) {
+ pr_warning("compressed sectors are not supported");
+ goto out_error;
+ }
+
+ clust_start &= QCOW_OFFSET_MASK;
if (!clust_start)
goto zero_cluster;
mutex_lock(&q->mutex);
- l2t_off = be64_to_cpu(table->l1_table[l1t_idx]) & ~header->oflag_mask;
+ l2t_off = be64_to_cpu(table->l1_table[l1t_idx]);
+ if (l2t_off & QCOW_OFLAG_COMPRESSED) {
+ pr_warning("compressed sectors are not supported");
+ goto error;
+ }
+
+ l2t_off &= QCOW_OFFSET_MASK;
if (l2t_off) {
/* read and cache l2 table */
l2t = qcow_read_l2_table(q, l2t_off);
if (!f_sz)
goto error;
- clust_start = be64_to_cpu(l2t->table[l2t_idx]) & ~header->oflag_mask;
+ clust_start = be64_to_cpu(l2t->table[l2t_idx]);
+ if (clust_start & QCOW_OFLAG_COMPRESSED) {
+ pr_warning("compressed sectors are not supported");
+ goto error;
+ }
+
+ clust_start &= QCOW_OFFSET_MASK;
if (!clust_start) {
clust_start = ALIGN(f_sz, clust_sz);
l2t->table[l2t_idx] = cpu_to_be64(clust_start);
.l1_size = f_header.l1_size,
.cluster_bits = f_header.cluster_bits,
.l2_bits = f_header.cluster_bits - 3,
- .oflag_mask = QCOW2_OFLAG_MASK,
};
return header;
.l1_size = f_header.size / ((1 << f_header.l2_bits) * (1 << f_header.cluster_bits)),
.cluster_bits = f_header.cluster_bits,
.l2_bits = f_header.l2_bits,
- .oflag_mask = QCOW1_OFLAG_MASK,
};
return header;
#define QCOW1_VERSION 1
#define QCOW2_VERSION 2
-#define QCOW1_OFLAG_COMPRESSED (1LL << 63)
+#define QCOW_OFLAG_COPIED (1ULL << 63)
+#define QCOW_OFLAG_COMPRESSED (1ULL << 62)
-#define QCOW1_OFLAG_MASK QCOW1_OFLAG_COMPRESSED
+#define QCOW_OFLAGS_MASK (QCOW_OFLAG_COPIED|QCOW_OFLAG_COMPRESSED)
-#define QCOW2_OFLAG_COPIED (1LL << 63)
-#define QCOW2_OFLAG_COMPRESSED (1LL << 62)
-#define QCOW2_OFLAG_MASK (QCOW2_OFLAG_COPIED|QCOW2_OFLAG_COMPRESSED)
+#define QCOW_OFFSET_MASK (~QCOW_OFLAGS_MASK)
#define MAX_CACHE_NODES 32
u32 l1_size;
u8 cluster_bits;
u8 l2_bits;
- u64 oflag_mask;
};
struct qcow1_header_disk {