x86/PVH: only set accessed/busy bits for present segments
authorJan Beulich <jbeulich@suse.com>
Tue, 24 Jan 2017 11:36:30 +0000 (12:36 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 24 Jan 2017 11:36:30 +0000 (12:36 +0100)
Commit 366ff5f1b3 ("x86: segment attribute handling adjustments" went a
little too far: We must not do such adjustments for non-present segments.

Reported-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/domain.c

index 5a4e7f9166104964ed9299e8672696fb7be1fcd5..71c0e3cd7378d6b69b470243998daa0c1e1bbf6f 100644 (file)
@@ -1374,8 +1374,10 @@ int arch_set_info_hvm_guest(struct vcpu *v, const vcpu_hvm_context_t *ctx)
 #define SEG(s, r) ({                                                        \
     s = (struct segment_register){ .base = (r)->s ## _base,                 \
                                    .limit = (r)->s ## _limit,               \
-                                   .attr.bytes = (r)->s ## _ar |            \
-                                       (x86_seg_##s != x86_seg_tr ? 1 : 2) }; \
+                                   .attr.bytes = (r)->s ## _ar };           \
+    /* Set accessed / busy bit for present segments. */                     \
+    if ( s.attr.fields.p )                                                  \
+        s.attr.fields.type |= (x86_seg_##s != x86_seg_tr ? 1 : 2);          \
     check_segment(&s, x86_seg_ ## s); })
 
         rc = SEG(cs, regs);