* [PATCH v2] x86: refine debugging of SMEP/SMAP fix
@ 2016-05-17 13:35 Jan Beulich
2016-05-17 13:37 ` Andrew Cooper
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2016-05-17 13:35 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Wei Liu
[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]
Instead of just latching cr4_pv32_mask into %rdx, correct the found
wrong value in %cr4 (to avoid triggering another BUG). The value left
in %rdx should be sufficient for deducing cr4_pv32_mask from the
register dump.
Also there is one more place for XEN_CR4_PV32_BITS to be used.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Preserve cr4_pv32_mask value in a register.
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -182,7 +182,7 @@ ENTRY(compat_restore_all_guest)
testb $3,UREGS_cs(%rsp)
jpe .Lcr4_alt_end
mov CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp), %rax
- and $~(X86_CR4_SMEP|X86_CR4_SMAP), %rax
+ and $~XEN_CR4_PV32_BITS, %rax
mov %rax, CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp)
mov %rax, %cr4
.Lcr4_alt_end:
@@ -220,6 +220,10 @@ ENTRY(cr4_pv32_restore)
je 1f
/* Cause cr4_pv32_mask to be visible in the BUG register dump. */
mov cr4_pv32_mask(%rip), %rdx
+ /* Avoid coming back here while handling the #UD we cause below. */
+ mov %cr4, %rcx
+ or %rdx, %rcx
+ mov %rcx, %cr4
BUG
1:
#endif
[-- Attachment #2: x86-SMEP-SMAP-addendum.patch --]
[-- Type: text/plain, Size: 1281 bytes --]
x86: refine debugging of SMEP/SMAP fix
Instead of just latching cr4_pv32_mask into %rdx, correct the found
wrong value in %cr4 (to avoid triggering another BUG). The value left
in %rdx should be sufficient for deducing cr4_pv32_mask from the
register dump.
Also there is one more place for XEN_CR4_PV32_BITS to be used.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Preserve cr4_pv32_mask value in a register.
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -182,7 +182,7 @@ ENTRY(compat_restore_all_guest)
testb $3,UREGS_cs(%rsp)
jpe .Lcr4_alt_end
mov CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp), %rax
- and $~(X86_CR4_SMEP|X86_CR4_SMAP), %rax
+ and $~XEN_CR4_PV32_BITS, %rax
mov %rax, CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp)
mov %rax, %cr4
.Lcr4_alt_end:
@@ -220,6 +220,10 @@ ENTRY(cr4_pv32_restore)
je 1f
/* Cause cr4_pv32_mask to be visible in the BUG register dump. */
mov cr4_pv32_mask(%rip), %rdx
+ /* Avoid coming back here while handling the #UD we cause below. */
+ mov %cr4, %rcx
+ or %rdx, %rcx
+ mov %rcx, %cr4
BUG
1:
#endif
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] x86: refine debugging of SMEP/SMAP fix
2016-05-17 13:35 [PATCH v2] x86: refine debugging of SMEP/SMAP fix Jan Beulich
@ 2016-05-17 13:37 ` Andrew Cooper
2016-05-17 13:37 ` Wei Liu
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2016-05-17 13:37 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Wei Liu
On 17/05/16 14:35, Jan Beulich wrote:
> Instead of just latching cr4_pv32_mask into %rdx, correct the found
> wrong value in %cr4 (to avoid triggering another BUG). The value left
> in %rdx should be sufficient for deducing cr4_pv32_mask from the
> register dump.
>
> Also there is one more place for XEN_CR4_PV32_BITS to be used.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] x86: refine debugging of SMEP/SMAP fix
2016-05-17 13:37 ` Andrew Cooper
@ 2016-05-17 13:37 ` Wei Liu
0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2016-05-17 13:37 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Wei Liu, Jan Beulich
On Tue, May 17, 2016 at 02:37:16PM +0100, Andrew Cooper wrote:
> On 17/05/16 14:35, Jan Beulich wrote:
> > Instead of just latching cr4_pv32_mask into %rdx, correct the found
> > wrong value in %cr4 (to avoid triggering another BUG). The value left
> > in %rdx should be sufficient for deducing cr4_pv32_mask from the
> > register dump.
> >
> > Also there is one more place for XEN_CR4_PV32_BITS to be used.
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-17 13:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-17 13:35 [PATCH v2] x86: refine debugging of SMEP/SMAP fix Jan Beulich
2016-05-17 13:37 ` Andrew Cooper
2016-05-17 13:37 ` Wei Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.