Re: [kvm-unit-tests v3 06/13] powerpc: Extract some common helpers and defines to headers

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

 



On 27/03/2023 14.45, Nicholas Piggin wrote:
Move some common helpers and defines to processor.h.

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

  lib/powerpc/asm/processor.h | 38 +++++++++++++++++++++++++++++++++----
  powerpc/spapr_hcall.c       |  9 +--------
  powerpc/sprs.c              |  9 ---------
  3 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/lib/powerpc/asm/processor.h b/lib/powerpc/asm/processor.h
index ebfeff2..4ad6612 100644
--- a/lib/powerpc/asm/processor.h
+++ b/lib/powerpc/asm/processor.h
@@ -9,13 +9,43 @@ void handle_exception(int trap, void (*func)(struct pt_regs *, void *), void *);
  void do_handle_exception(struct pt_regs *regs);
  #endif /* __ASSEMBLY__ */
-static inline uint64_t get_tb(void)
+#define SPR_TB		0x10c
+#define SPR_SPRG0	0x110
+#define SPR_SPRG1	0x111
+#define SPR_SPRG2	0x112
+#define SPR_SPRG3	0x113
+
+static inline uint64_t mfspr(int nr)
  {
-	uint64_t tb;
+	uint64_t ret;
+
+	asm volatile("mfspr %0,%1" : "=r"(ret) : "i"(nr) : "memory");
+
+	return ret;
+}
- asm volatile ("mfspr %[tb],268" : [tb] "=r" (tb));
+static inline void mtspr(int nr, uint64_t val)
+{
+	asm volatile("mtspr %0,%1" : : "i"(nr), "r"(val) : "memory");
+}

I'd maybe use __always_inline for the above two helper functions, since "nr" is used with immediate constraint in the asm part.

Did you also check whether this works with Clang ? (IIRC I saw issues with that on other occasions in the past)

Anyway:
Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx>




[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