[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 06/16] x86/amd: call post outb hook for both PV and HVM



The issue described in 10d03342912 is applicable to both PV and HVM
domains that have access to that SMI CMD port.

Move the hook to AMD code, remove its pv_ prefix and call it in both
PV and HVM code.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
v2: rewritten
---
 xen/arch/x86/cpu/amd.c         |  4 +++-
 xen/arch/x86/hvm/io.c          |  2 ++
 xen/arch/x86/pv/emul-priv-op.c | 10 ++++------
 xen/include/asm-x86/io.h       |  2 +-
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index c394c1c..9ab5e84 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -44,6 +44,8 @@ integer_param("cpuid_mask_thermal_ecx", 
opt_cpuid_mask_thermal_ecx);
 s8 __read_mostly opt_allow_unsafe;
 boolean_param("allow_unsafe", opt_allow_unsafe);
 
+void (*post_outb_hook)(unsigned int port, uint8_t value);
+
 static inline int rdmsr_amd_safe(unsigned int msr, unsigned int *lo,
                                 unsigned int *hi)
 {
@@ -628,7 +630,7 @@ static void init_amd(struct cpuinfo_x86 *c)
        case 0xf ... 0x17:
                disable_c1e(NULL);
                if (acpi_smi_cmd && (acpi_enable_value | acpi_disable_value))
-                       pv_post_outb_hook = check_disable_c1e;
+                       post_outb_hook = check_disable_c1e;
                break;
        }
 
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index a5b0a23..896874d 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -234,6 +234,8 @@ static int g2m_portio_write(const struct hvm_io_handler 
*handler,
     {
     case 1:
         outb(data, mport);
+        if ( post_outb_hook )
+            post_outb_hook(mport, (uint8_t)data);
         break;
     case 2:
         outw(data, mport);
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index b85c65f..e99cbcc 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -59,8 +59,6 @@ struct priv_op_ctxt {
 void host_to_guest_gpr_switch(struct cpu_user_regs *);
 unsigned long guest_to_host_gpr_switch(unsigned long);
 
-void (*pv_post_outb_hook)(unsigned int port, u8 value);
-
 typedef void io_emul_stub_t(struct cpu_user_regs *);
 
 static io_emul_stub_t *io_emul_stub_setup(struct priv_op_ctxt *ctxt, u8 opcode,
@@ -352,8 +350,8 @@ static void guest_io_write(unsigned int port, unsigned int 
bytes,
         {
         case 1:
             outb((uint8_t)data, port);
-            if ( pv_post_outb_hook )
-                pv_post_outb_hook(port, (uint8_t)data);
+            if ( post_outb_hook )
+                post_outb_hook(port, (uint8_t)data);
             break;
         case 2:
             outw((uint16_t)data, port);
@@ -433,8 +431,8 @@ static int write_io(unsigned int port, unsigned int bytes,
             io_emul_stub_setup(poc, ctxt->opcode, port, bytes);
 
         io_emul(ctxt->regs);
-        if ( (bytes == 1) && pv_post_outb_hook )
-            pv_post_outb_hook(port, val);
+        if ( (bytes == 1) && post_outb_hook )
+            post_outb_hook(port, val);
         return X86EMUL_DONE;
     }
 
diff --git a/xen/include/asm-x86/io.h b/xen/include/asm-x86/io.h
index 4d2064e..0326e9d 100644
--- a/xen/include/asm-x86/io.h
+++ b/xen/include/asm-x86/io.h
@@ -48,7 +48,7 @@ __OUT(b,"b",char)
 __OUT(w,"w",short)
 __OUT(l,,int)
 
-extern void (*pv_post_outb_hook)(unsigned int port, u8 value);
+extern void (*post_outb_hook)(unsigned int port, u8 value);
 
 /* Function pointer used to handle platform specific I/O port emulation. */
 #define IOEMUL_QUIRK_STUB_BYTES 10
-- 
git-series 0.9.1

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.