]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
idt: Constify the xtf_idte parameter to xtf_set_idte()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 15 Nov 2019 13:23:03 +0000 (13:23 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 28 Nov 2019 23:24:14 +0000 (23:24 +0000)
It is only ever read.  Take the opportunity to adjust all callers to construct
their struct xtf_idte in .rodata.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/hvm/traps.c
arch/x86/include/arch/idt.h
arch/x86/pv/traps.c
tests/selftest/main.c
tests/xsa-186/main.c
tests/xsa-192/main.c
tests/xsa-196/main.c
tests/xsa-213/main.c

index 1e3df526dc80b797f8bdda1bcd8af3013bec4595..ae3d3ef35b62aa7e7b5739e8dfae67df1632bb36 100644 (file)
@@ -70,7 +70,7 @@ static env_tss tss_DF __aligned(16) =
     .iopb = X86_TSS_INVALID_IO_BITMAP,
 };
 
-int xtf_set_idte(unsigned int vector, struct xtf_idte *idte)
+int xtf_set_idte(unsigned int vector, const struct xtf_idte *idte)
 {
     pack_intr_gate(&idt[vector], idte->cs, idte->addr, idte->dpl, 0);
 
index 0a08f90a82f87ef419e1071921331ea4967a6275..02955d54bae4aa148671396c1913432d95823562 100644 (file)
@@ -40,7 +40,7 @@ struct xtf_idte
  * @returns 0 for HVM guests, hypercall result for PV guests.
  */
 int xtf_set_idte(unsigned int vector,
-                 struct xtf_idte *idte);
+                 const struct xtf_idte *idte);
 
 #endif /* __ASSEMBLY__ */
 
index 3ff6cefa5840492c4ec4d730f66ca0c121452c64..e70a680ead98fd37650bbdeaf11b9c1ba4dbebdd 100644 (file)
@@ -65,7 +65,7 @@ struct xen_trap_info pv_default_trap_info[] =
     { 0, 0, 0, 0 }, /* Sentinel. */
 };
 
-int xtf_set_idte(unsigned int vector, struct xtf_idte *idte)
+int xtf_set_idte(unsigned int vector, const struct xtf_idte *idte)
 {
     struct xen_trap_info ti[2] =
     {
index e39f1e795a7b0106b64f343faa192b561bbf0b55..a376df38c12018688c3ab26049dab60d298076de 100644 (file)
@@ -266,16 +266,15 @@ asm ("test_idte_handler:;"
 #endif
     );
 
+static const struct xtf_idte idte = {
+    .addr = _u(test_idte_handler),
+    /* PV guests need DPL1, HVM need DPL0. */
+    .dpl = IS_DEFINED(CONFIG_PV) ? 1 : 0,
+    .cs = __KERN_CS,
+};
+
 static void test_custom_idte(void)
 {
-    struct xtf_idte idte =
-        {
-            .addr = _u(test_idte_handler),
-            /* PV guests need DPL1, HVM need DPL0. */
-            .dpl = IS_DEFINED(CONFIG_PV) ? 1 : 0,
-            .cs = __KERN_CS,
-        };
-
     printk("Test: Custom IDT entry\n");
 
     int rc = xtf_set_idte(X86_VEC_AVAIL, &idte);
index d39eca83e3d7abdeedbae11e75be4e5571d14a20..726acf32dc21f19c882068883b7f6706a21fec89 100644 (file)
@@ -47,6 +47,11 @@ asm(".align 16;"
     "iret"
     );
 
+static const struct xtf_idte idte = {
+    .addr = _u(test_int_handler),
+    .cs = __KERN_CS,
+};
+
 /* Stub instruction buffer. */
 asm(".align 16;"
     "insn_stub_start:;"
@@ -75,12 +80,6 @@ static bool ex_fault(struct cpu_regs *regs, const struct extable_entry *ex)
 
 void test_main(void)
 {
-    struct xtf_idte idte =
-    {
-        .addr = _u(test_int_handler),
-        .cs = __KERN_CS,
-    };
-
     /* Hook test_int_handler() into the real IDT. */
     xtf_set_idte(X86_VEC_AVAIL, &idte);
 
index 1cf0f97c87699ae0e2d43ac2053569e09a469e48..326ba2055524583c717f84fec26fc1f7adfc6446 100644 (file)
@@ -36,6 +36,12 @@ asm(".align 16;"
     "jmp .Ltss_ret_point;"
     );
 
+static const struct xtf_idte idte = {
+    .addr = _u(ret_from_vm86),
+    .cs   = __KERN_CS,
+    .dpl  = 3,
+};
+
 /* Virtual 8068 task. */
 env_tss vm86_tss __aligned(16) =
 {
@@ -75,13 +81,6 @@ unsigned long user_ldt_use(void)
 
 void test_main(void)
 {
-    struct xtf_idte idte =
-    {
-        .addr = _u(ret_from_vm86),
-        .cs   = __KERN_CS,
-        .dpl  = 3,
-    };
-
     /* Hook ret_from_vm86(). */
     xtf_set_idte(X86_VEC_AVAIL, &idte);
 
index 272108c5a3fb9f21f5026277ac2986d7bb85b56a..f50c333a636474b95ffa0b95c3e95b5ae84e17be 100644 (file)
@@ -37,6 +37,11 @@ asm(".align 16;"
     "iretq;"
     );
 
+static const struct xtf_idte idte = {
+    .addr = _u(custom_doublefault_handler),
+    .cs   = __KERN_CS,
+};
+
 unsigned long compat_userspace(void)
 {
     exinfo_t fault = 0;
@@ -76,13 +81,6 @@ void test_main(void)
     ASSERT(idt[X86_EXC_OF].dpl == 3);
     ASSERT(idt[X86_EXC_DF].dpl == 0);
 
-    struct xtf_idte idte =
-    {
-        .addr = _u(custom_doublefault_handler),
-        .cs   = __KERN_CS,
-        .dpl  = 0,
-    };
-
     /* Hook the custom doublefault handler. */
     xtf_set_idte(X86_EXC_DF, &idte);
 
index a0c8a1b0d1c00aacb8da47eba9ebd2443895b173..64e7065eba64307d2b826c77b418e561d2a90c26 100644 (file)
@@ -34,6 +34,12 @@ asm(".align 16;"
     "jmp multicall_return;"
     );
 
+static const struct xtf_idte idte = {
+    .addr = _u(recover_from_iret),
+    .cs   = __KERN_CS,
+    .dpl  = 3,
+};
+
 /* Target of the __HYPERVISOR_iret hypercall. */
 void iret_entry(void);
 asm (".pushsection .text.user;"
@@ -111,13 +117,6 @@ static multicall_entry_t multi[] = {
     },
 };
 
-static struct xtf_idte idte =
-{
-    .addr = (unsigned long)recover_from_iret,
-    .cs   = __KERN_CS,
-    .dpl  = 3,
-};
-
 void test_main(void)
 {
     long rc, xen_version = hypercall_xen_version(XENVER_version, NULL);