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

Re: [Xen-devel] [PATCH] xen/arm: trap SMC instructions and inject an UND exception



On Thu, 2013-05-02 at 12:01 +0100, Ian Campbell wrote:
> Currently only handles 32 bit guests. The 64-bit exception model is
> considerably different.
> 
> Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

Tested with the following Linux patch...


diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 234e339..dbf2d03 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -43,6 +43,7 @@
 #include <asm/cacheflush.h>
 #include <asm/cachetype.h>
 #include <asm/tlbflush.h>
+#include <asm/opcodes-sec.h>
 
 #include <asm/prom.h>
 #include <asm/mach/arch.h>
@@ -730,6 +731,43 @@ static int __init meminfo_cmp(const void *_a, const void 
*_b)
        return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
 }
 
+static int __initdata test_und_count = 0;
+
+static int __init test_und_handler(struct pt_regs *regs, unsigned int instr)
+{
+       test_und_count++;
+       regs->ARM_pc += 4;
+       return 0;
+}
+
+static struct __initdata undef_hook und_hook = {
+       .instr_mask     = 0,
+       .instr_val      = 0,
+       .cpsr_mask      = MODE_MASK,
+       .cpsr_val       = SVC_MODE,
+       .fn             = test_und_handler,
+};
+
+static void __init test_und(void)
+{
+       int before = test_und_count;
+
+       register_undef_hook(&und_hook);
+       printk(KERN_INFO "Testing UND instruction... ");
+       asm volatile(".long 0xe7f000f0" : : : "memory");
+       printk(KERN_CONT "%s with count %d\n",
+              (before + 1) == test_und_count ? "success" : "failure",
+              test_und_count);
+
+       printk(KERN_INFO "Testing SMC instruction... ");
+       before = test_und_count;
+       asm volatile(__SMC(0) : : : "memory");
+       printk(KERN_CONT "%s with count %d\n",
+              (before + 1) == test_und_count ? "success" : "failure",
+              test_und_count);
+       unregister_undef_hook(&und_hook);
+}
+
 void __init hyp_mode_check(void)
 {
 #ifdef CONFIG_ARM_VIRT_EXT
@@ -784,6 +822,8 @@ void __init setup_arch(char **cmdline_p)
 
        unflatten_device_tree();
 
+       test_und();
+
        arm_dt_init_cpu_maps();
 #ifdef CONFIG_SMP
        if (is_smp()) {



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


 


Rackspace

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