All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/PV: restrict permitted instructions during memory write emulation
@ 2017-01-18 15:26 Jan Beulich
  2017-01-18 16:54 ` Andrew Cooper
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2017-01-18 15:26 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]

All three code paths mean to only emulate memory writes. Refuse
emulation of any other instructions there.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This would effectively allow us to revert 0e47f92b07 ("x86: force
EFLAGS.IF on when exiting to PV guests").

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5340,11 +5340,19 @@ static int ptwr_emulated_cmpxchg(
         container_of(ctxt, struct ptwr_emulate_ctxt, ctxt));
 }
 
+static int pv_emul_is_mem_write(const struct x86_emulate_state *state,
+                                struct x86_emulate_ctxt *ctxt)
+{
+    return x86_insn_is_mem_write(state, ctxt) ? X86EMUL_OKAY
+                                              : X86EMUL_UNHANDLEABLE;
+}
+
 static const struct x86_emulate_ops ptwr_emulate_ops = {
     .read       = ptwr_emulated_read,
     .insn_fetch = ptwr_emulated_read,
     .write      = ptwr_emulated_write,
     .cmpxchg    = ptwr_emulated_cmpxchg,
+    .validate   = pv_emul_is_mem_write,
     .cpuid      = pv_emul_cpuid,
 };
 
@@ -5463,6 +5471,7 @@ static const struct x86_emulate_ops mmio
     .read       = x86emul_unhandleable_rw,
     .insn_fetch = ptwr_emulated_read,
     .write      = mmio_ro_emulated_write,
+    .validate   = pv_emul_is_mem_write,
     .cpuid      = pv_emul_cpuid,
 };
 
@@ -5501,6 +5510,7 @@ static const struct x86_emulate_ops mmcf
     .read       = x86emul_unhandleable_rw,
     .insn_fetch = ptwr_emulated_read,
     .write      = mmcfg_intercept_write,
+    .validate   = pv_emul_is_mem_write,
     .cpuid      = pv_emul_cpuid,
 };
 




[-- Attachment #2: x86-PV-filter-insn.patch --]
[-- Type: text/plain, Size: 1675 bytes --]

x86/PV: restrict permitted instructions during memory write emulation

All three code paths mean to only emulate memory writes. Refuse
emulation of any other instructions there.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This would effectively allow us to revert 0e47f92b07 ("x86: force
EFLAGS.IF on when exiting to PV guests").

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5340,11 +5340,19 @@ static int ptwr_emulated_cmpxchg(
         container_of(ctxt, struct ptwr_emulate_ctxt, ctxt));
 }
 
+static int pv_emul_is_mem_write(const struct x86_emulate_state *state,
+                                struct x86_emulate_ctxt *ctxt)
+{
+    return x86_insn_is_mem_write(state, ctxt) ? X86EMUL_OKAY
+                                              : X86EMUL_UNHANDLEABLE;
+}
+
 static const struct x86_emulate_ops ptwr_emulate_ops = {
     .read       = ptwr_emulated_read,
     .insn_fetch = ptwr_emulated_read,
     .write      = ptwr_emulated_write,
     .cmpxchg    = ptwr_emulated_cmpxchg,
+    .validate   = pv_emul_is_mem_write,
     .cpuid      = pv_emul_cpuid,
 };
 
@@ -5463,6 +5471,7 @@ static const struct x86_emulate_ops mmio
     .read       = x86emul_unhandleable_rw,
     .insn_fetch = ptwr_emulated_read,
     .write      = mmio_ro_emulated_write,
+    .validate   = pv_emul_is_mem_write,
     .cpuid      = pv_emul_cpuid,
 };
 
@@ -5501,6 +5510,7 @@ static const struct x86_emulate_ops mmcf
     .read       = x86emul_unhandleable_rw,
     .insn_fetch = ptwr_emulated_read,
     .write      = mmcfg_intercept_write,
+    .validate   = pv_emul_is_mem_write,
     .cpuid      = pv_emul_cpuid,
 };
 

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/PV: restrict permitted instructions during memory write emulation
  2017-01-18 15:26 [PATCH] x86/PV: restrict permitted instructions during memory write emulation Jan Beulich
@ 2017-01-18 16:54 ` Andrew Cooper
  2017-01-18 17:19   ` Jan Beulich
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2017-01-18 16:54 UTC (permalink / raw)
  To: Jan Beulich, xen-devel

On 18/01/17 15:26, Jan Beulich wrote:
> All three code paths mean to only emulate memory writes. Refuse
> emulation of any other instructions there.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> This would effectively allow us to revert 0e47f92b07 ("x86: force
> EFLAGS.IF on when exiting to PV guests").
>
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -5340,11 +5340,19 @@ static int ptwr_emulated_cmpxchg(
>          container_of(ctxt, struct ptwr_emulate_ctxt, ctxt));
>  }
>  
> +static int pv_emul_is_mem_write(const struct x86_emulate_state *state,
> +                                struct x86_emulate_ctxt *ctxt)
> +{
> +    return x86_insn_is_mem_write(state, ctxt) ? X86EMUL_OKAY
> +                                              : X86EMUL_UNHANDLEABLE;
> +}
> +
>  static const struct x86_emulate_ops ptwr_emulate_ops = {
>      .read       = ptwr_emulated_read,
>      .insn_fetch = ptwr_emulated_read,
>      .write      = ptwr_emulated_write,
>      .cmpxchg    = ptwr_emulated_cmpxchg,
> +    .validate   = pv_emul_is_mem_write,

.validate = x86_insn_is_mem_write,  ?

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/PV: restrict permitted instructions during memory write emulation
  2017-01-18 16:54 ` Andrew Cooper
@ 2017-01-18 17:19   ` Jan Beulich
  2017-01-18 17:26     ` Andrew Cooper
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2017-01-18 17:19 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel

>>> On 18.01.17 at 17:54, <andrew.cooper3@citrix.com> wrote:
> On 18/01/17 15:26, Jan Beulich wrote:
>> --- a/xen/arch/x86/mm.c
>> +++ b/xen/arch/x86/mm.c
>> @@ -5340,11 +5340,19 @@ static int ptwr_emulated_cmpxchg(
>>          container_of(ctxt, struct ptwr_emulate_ctxt, ctxt));
>>  }
>>  
>> +static int pv_emul_is_mem_write(const struct x86_emulate_state *state,
>> +                                struct x86_emulate_ctxt *ctxt)
>> +{
>> +    return x86_insn_is_mem_write(state, ctxt) ? X86EMUL_OKAY
>> +                                              : X86EMUL_UNHANDLEABLE;
>> +}
>> +
>>  static const struct x86_emulate_ops ptwr_emulate_ops = {
>>      .read       = ptwr_emulated_read,
>>      .insn_fetch = ptwr_emulated_read,
>>      .write      = ptwr_emulated_write,
>>      .cmpxchg    = ptwr_emulated_cmpxchg,
>> +    .validate   = pv_emul_is_mem_write,
> 
> .validate = x86_insn_is_mem_write,  ?

Nope, types don't match (and I also don't want to make them
match).

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/PV: restrict permitted instructions during memory write emulation
  2017-01-18 17:19   ` Jan Beulich
@ 2017-01-18 17:26     ` Andrew Cooper
  2017-01-19  8:09       ` Jan Beulich
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2017-01-18 17:26 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel

On 18/01/17 17:19, Jan Beulich wrote:
>>>> On 18.01.17 at 17:54, <andrew.cooper3@citrix.com> wrote:
>> On 18/01/17 15:26, Jan Beulich wrote:
>>> --- a/xen/arch/x86/mm.c
>>> +++ b/xen/arch/x86/mm.c
>>> @@ -5340,11 +5340,19 @@ static int ptwr_emulated_cmpxchg(
>>>          container_of(ctxt, struct ptwr_emulate_ctxt, ctxt));
>>>  }
>>>  
>>> +static int pv_emul_is_mem_write(const struct x86_emulate_state *state,
>>> +                                struct x86_emulate_ctxt *ctxt)
>>> +{
>>> +    return x86_insn_is_mem_write(state, ctxt) ? X86EMUL_OKAY
>>> +                                              : X86EMUL_UNHANDLEABLE;
>>> +}
>>> +
>>>  static const struct x86_emulate_ops ptwr_emulate_ops = {
>>>      .read       = ptwr_emulated_read,
>>>      .insn_fetch = ptwr_emulated_read,
>>>      .write      = ptwr_emulated_write,
>>>      .cmpxchg    = ptwr_emulated_cmpxchg,
>>> +    .validate   = pv_emul_is_mem_write,
>> .validate = x86_insn_is_mem_write,  ?
> Nope, types don't match (and I also don't want to make them
> match).

Oh, right.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/PV: restrict permitted instructions during memory write emulation
  2017-01-18 17:26     ` Andrew Cooper
@ 2017-01-19  8:09       ` Jan Beulich
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2017-01-19  8:09 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel

>>> On 18.01.17 at 18:26, <andrew.cooper3@citrix.com> wrote:
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Thanks. What are your thoughts about this remark

>> This would effectively allow us to revert 0e47f92b07 ("x86: force
>> EFLAGS.IF on when exiting to PV guests").

then?

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-19  8:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 15:26 [PATCH] x86/PV: restrict permitted instructions during memory write emulation Jan Beulich
2017-01-18 16:54 ` Andrew Cooper
2017-01-18 17:19   ` Jan Beulich
2017-01-18 17:26     ` Andrew Cooper
2017-01-19  8:09       ` Jan Beulich

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.