[kvm-unit-tests v3 09/13] powerpc: Expand exception handler vector granularity

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

 



Exception handlers are currently indexed in units of 0x100, but
powerpc can have vectors that are aligned to as little as 0x20
bytes. Increase granularity of the handler functions before
adding support for thse vectors.

Signed-off-by: Nicholas Piggin <npiggin@xxxxxxxxx>
---
Since v2:
- New patch

 lib/powerpc/processor.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/powerpc/processor.c b/lib/powerpc/processor.c
index f8b7905..411e013 100644
--- a/lib/powerpc/processor.c
+++ b/lib/powerpc/processor.c
@@ -16,19 +16,24 @@
 static struct {
 	void (*func)(struct pt_regs *, void *data);
 	void *data;
-} handlers[16];
+} handlers[128];
 
+/*
+ * Exception handlers span from 0x100 to 0x1000 and can have a granularity
+ * of 0x20 bytes in some cases. Indexing spans 0-0x1000 with 0x20 increments
+ * resulting in 128 slots.
+ */
 void handle_exception(int trap, void (*func)(struct pt_regs *, void *),
 		      void * data)
 {
-	if (trap & 0xff) {
+	if (trap & 0x1f) {
 		printf("invalid exception handler %#x\n", trap);
 		abort();
 	}
 
-	trap >>= 8;
+	trap >>= 5;
 
-	if (trap < 16) {
+	if (trap < 128) {
 		if (func && handlers[trap].func) {
 			printf("exception handler installed twice %#x\n", trap);
 			abort();
@@ -45,9 +50,9 @@ void do_handle_exception(struct pt_regs *regs)
 {
 	unsigned char v;
 
-	v = regs->trap >> 8;
+	v = regs->trap >> 5;
 
-	if (v < 16 && handlers[v].func) {
+	if (v < 128 && handlers[v].func) {
 		handlers[v].func(regs, handlers[v].data);
 		return;
 	}
-- 
2.37.2




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux