]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86/traps: Move guest_{rd,wr}msr_xen() into msr.c
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 31 Dec 2024 11:02:49 +0000 (11:02 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Jan 2025 14:19:10 +0000 (14:19 +0000)
They are out of place in traps.c, and only have a single caller each.  Make
them static inside msr.c.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/include/asm/processor.h
xen/arch/x86/msr.c
xen/arch/x86/traps.c

index 4f176bc575ef64174476d4469a7f603304519842..6bc88b031761211341c77268b483671e1bb4a389 100644 (file)
@@ -472,9 +472,6 @@ struct stubs {
 DECLARE_PER_CPU(struct stubs, stubs);
 unsigned long alloc_stub_page(unsigned int cpu, unsigned long *mfn);
 
-int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val);
-int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val);
-
 static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model,
                                      uint8_t *stepping)
 {
index 2244571939ee7c176729e68d7db9ead7f80e69c4..a12503608c16ac33dd2eea4e24ab7e4baff1aee6 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/hvm/nestedhvm.h>
 #include <asm/hvm/viridian.h>
 #include <asm/msr.h>
+#include <asm/p2m.h>
 #include <asm/pv/domain.h>
 #include <asm/setup.h>
 #include <asm/xstate.h>
@@ -40,6 +41,78 @@ int init_vcpu_msr_policy(struct vcpu *v)
     return 0;
 }
 
+static int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val)
+{
+    const struct domain *d = v->domain;
+    /* Optionally shift out of the way of Viridian architectural MSRs. */
+    uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000;
+
+    switch ( idx - base )
+    {
+    case 0: /* Write hypercall page MSR.  Read as zero. */
+        *val = 0;
+        return X86EMUL_OKAY;
+    }
+
+    return X86EMUL_EXCEPTION;
+}
+
+static int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val)
+{
+    struct domain *d = v->domain;
+    /* Optionally shift out of the way of Viridian architectural MSRs. */
+    uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000;
+
+    switch ( idx - base )
+    {
+    case 0: /* Write hypercall page */
+    {
+        void *hypercall_page;
+        unsigned long gmfn = val >> PAGE_SHIFT;
+        unsigned int page_index = val & (PAGE_SIZE - 1);
+        struct page_info *page;
+        p2m_type_t t;
+
+        if ( page_index > 0 )
+        {
+            gdprintk(XENLOG_WARNING,
+                     "wrmsr hypercall page index %#x unsupported\n",
+                     page_index);
+            return X86EMUL_EXCEPTION;
+        }
+
+        page = get_page_from_gfn(d, gmfn, &t, P2M_ALLOC);
+
+        if ( !page || !get_page_type(page, PGT_writable_page) )
+        {
+            if ( page )
+                put_page(page);
+
+            if ( p2m_is_paging(t) )
+            {
+                p2m_mem_paging_populate(d, _gfn(gmfn));
+                return X86EMUL_RETRY;
+            }
+
+            gdprintk(XENLOG_WARNING,
+                     "Bad GMFN %lx (MFN %#"PRI_mfn") to MSR %08x\n",
+                     gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN), base);
+            return X86EMUL_EXCEPTION;
+        }
+
+        hypercall_page = __map_domain_page(page);
+        init_hypercall_page(d, hypercall_page);
+        unmap_domain_page(hypercall_page);
+
+        put_page_and_type(page);
+        return X86EMUL_OKAY;
+    }
+
+    default:
+        return X86EMUL_EXCEPTION;
+    }
+}
+
 int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
 {
     const struct vcpu *curr = current;
index f28d46a49aaa96050f51bd39a79cb463ebc40c98..740a60399d02d763d5a7986ef203187f36dabe64 100644 (file)
@@ -64,7 +64,6 @@
 #include <asm/mc146818rtc.h>
 #include <asm/hpet.h>
 #include <asm/vpmu.h>
-#include <public/hvm/params.h>
 #include <asm/cpuid.h>
 #include <xsm/xsm.h>
 #include <asm/irq-vectors.h>
@@ -978,78 +977,6 @@ void asmlinkage do_trap(struct cpu_user_regs *regs)
     fatal_trap(regs, false);
 }
 
-int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val)
-{
-    const struct domain *d = v->domain;
-    /* Optionally shift out of the way of Viridian architectural MSRs. */
-    uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000;
-
-    switch ( idx - base )
-    {
-    case 0: /* Write hypercall page MSR.  Read as zero. */
-        *val = 0;
-        return X86EMUL_OKAY;
-    }
-
-    return X86EMUL_EXCEPTION;
-}
-
-int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val)
-{
-    struct domain *d = v->domain;
-    /* Optionally shift out of the way of Viridian architectural MSRs. */
-    uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000;
-
-    switch ( idx - base )
-    {
-    case 0: /* Write hypercall page */
-    {
-        void *hypercall_page;
-        unsigned long gmfn = val >> PAGE_SHIFT;
-        unsigned int page_index = val & (PAGE_SIZE - 1);
-        struct page_info *page;
-        p2m_type_t t;
-
-        if ( page_index > 0 )
-        {
-            gdprintk(XENLOG_WARNING,
-                     "wrmsr hypercall page index %#x unsupported\n",
-                     page_index);
-            return X86EMUL_EXCEPTION;
-        }
-
-        page = get_page_from_gfn(d, gmfn, &t, P2M_ALLOC);
-
-        if ( !page || !get_page_type(page, PGT_writable_page) )
-        {
-            if ( page )
-                put_page(page);
-
-            if ( p2m_is_paging(t) )
-            {
-                p2m_mem_paging_populate(d, _gfn(gmfn));
-                return X86EMUL_RETRY;
-            }
-
-            gdprintk(XENLOG_WARNING,
-                     "Bad GMFN %lx (MFN %#"PRI_mfn") to MSR %08x\n",
-                     gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN), base);
-            return X86EMUL_EXCEPTION;
-        }
-
-        hypercall_page = __map_domain_page(page);
-        init_hypercall_page(d, hypercall_page);
-        unmap_domain_page(hypercall_page);
-
-        put_page_and_type(page);
-        return X86EMUL_OKAY;
-    }
-
-    default:
-        return X86EMUL_EXCEPTION;
-    }
-}
-
 void asmlinkage do_invalid_op(struct cpu_user_regs *regs)
 {
     u8 bug_insn[2];