From: Jan Kiszka <[email protected]>

This is arch-specific, and it only has callers in mmio.c.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/arm/include/asm/bitops.h   | 12 ------------
 hypervisor/arch/arm/mmio.c                 | 12 ++++++++++--
 hypervisor/arch/arm64/include/asm/bitops.h | 13 -------------
 hypervisor/arch/arm64/mmio.c               | 13 +++++++++++--
 4 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/hypervisor/arch/arm/include/asm/bitops.h 
b/hypervisor/arch/arm/include/asm/bitops.h
index 34b1fe1b..3b5d0a89 100644
--- a/hypervisor/arch/arm/include/asm/bitops.h
+++ b/hypervisor/arch/arm/include/asm/bitops.h
@@ -121,17 +121,5 @@ static inline unsigned long ffzl(unsigned long word)
        return ffsl(~word);
 }
 
-/* Extend the value of 'size' bits to a signed long */
-static inline unsigned long sign_extend(unsigned long val, unsigned int size)
-{
-       unsigned long mask;
-
-       if (size >= sizeof(unsigned long) * 8)
-               return val;
-
-       mask = 1U << (size - 1);
-       return (val ^ mask) - mask;
-}
-
 #endif /* !__ASSEMBLY__ */
 #endif /* !_JAILHOUSE_ASM_BITOPS_H */
diff --git a/hypervisor/arch/arm/mmio.c b/hypervisor/arch/arm/mmio.c
index 726ea751..fcc7fdf2 100644
--- a/hypervisor/arch/arm/mmio.c
+++ b/hypervisor/arch/arm/mmio.c
@@ -18,6 +18,14 @@
 #include <asm/processor.h>
 #include <asm/traps.h>
 
+/* Extend the value of 'size' bits to a signed long */
+static inline unsigned long sign_extend(unsigned long val, unsigned int size)
+{
+       unsigned long mask = 1UL << (size - 1);
+
+       return (val ^ mask) - mask;
+}
+
 /* Taken from the ARM ARM pseudocode for taking a data abort */
 static void arch_inject_dabt(struct trap_context *ctx, unsigned long addr)
 {
@@ -103,7 +111,7 @@ enum trap_return arch_handle_dabt(struct trap_context *ctx)
        if (is_write) {
                /* Load the value to write from the src register */
                access_cell_reg(ctx, srt, &mmio.value, true);
-               if (sse)
+               if (sse && size < sizeof(unsigned long))
                        mmio.value = sign_extend(mmio.value, 8 * size);
        } else {
                mmio.value = 0;
@@ -119,7 +127,7 @@ enum trap_return arch_handle_dabt(struct trap_context *ctx)
 
        /* Put the read value into the dest register */
        if (!is_write) {
-               if (sse)
+               if (sse && size < sizeof(unsigned long))
                        mmio.value = sign_extend(mmio.value, 8 * size);
                access_cell_reg(ctx, srt, &mmio.value, false);
        }
diff --git a/hypervisor/arch/arm64/include/asm/bitops.h 
b/hypervisor/arch/arm64/include/asm/bitops.h
index b7dd6204..aad70f29 100644
--- a/hypervisor/arch/arm64/include/asm/bitops.h
+++ b/hypervisor/arch/arm64/include/asm/bitops.h
@@ -124,18 +124,5 @@ static inline unsigned long ffzl(unsigned long word)
        return ffsl(~word);
 }
 
-/* AARCH64_TODO: we can use SXTB, SXTH, SXTW */
-/* Extend the value of 'size' bits to a signed long */
-static inline unsigned long sign_extend(unsigned long val, unsigned int size)
-{
-       unsigned long mask;
-
-       if (size >= sizeof(unsigned long) * 8)
-               return val;
-
-       mask = 1ul << (size - 1);
-       return (val ^ mask) - mask;
-}
-
 #endif /* !__ASSEMBLY__ */
 #endif /* !_JAILHOUSE_ASM_BITOPS_H */
diff --git a/hypervisor/arch/arm64/mmio.c b/hypervisor/arch/arm64/mmio.c
index 4961b030..e6933716 100644
--- a/hypervisor/arch/arm64/mmio.c
+++ b/hypervisor/arch/arm64/mmio.c
@@ -24,6 +24,15 @@
 
 /* AARCH64_TODO: consider merging this with the AArch32 version */
 
+/* AARCH64_TODO: we can use SXTB, SXTH, SXTW */
+/* Extend the value of 'size' bits to a signed long */
+static inline unsigned long sign_extend(unsigned long val, unsigned int size)
+{
+       unsigned long mask = 1UL << (size - 1);
+
+       return (val ^ mask) - mask;
+}
+
 static void arch_inject_dabt(struct trap_context *ctx, unsigned long addr)
 {
        int err __attribute__((unused)) = trace_error(-EINVAL);
@@ -71,7 +80,7 @@ enum trap_return arch_handle_dabt(struct trap_context *ctx)
        if (is_write) {
                /* Load the value to write from the src register */
                mmio.value = (srt == 31) ? 0 : ctx->regs[srt];
-               if (sse)
+               if (sse && size < sizeof(unsigned long))
                        mmio.value = sign_extend(mmio.value, 8 * size);
        } else {
                mmio.value = 0;
@@ -87,7 +96,7 @@ enum trap_return arch_handle_dabt(struct trap_context *ctx)
 
        /* Put the read value into the dest register */
        if (!is_write && (srt != 31)) {
-               if (sse)
+               if (sse && size < sizeof(unsigned long))
                        mmio.value = sign_extend(mmio.value, 8 * size);
                ctx->regs[srt] = mmio.value;
        }
-- 
2.16.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/46430c0f31887600ed4f11189dec4e25e1901fdb.1581930651.git.jan.kiszka%40siemens.com.

Reply via email to