Skip to contentSkip to conversation

KVM: PPC: Ultravisor: generic ucall handler plpar_ucall()

PATCH In review Ram Pai 2 participants 2 messages Jan 22, 2019 PowerPC

lore
Share & tools
lore

Ram Pai

author
#0 lore raw

PATCH 1/13 KVM: PPC: Ultravisor: generic ucall handler plpar_ucall()

plpar_ucall() function can now be used to make ucalls with varied number of in and out arguments. It handles 4 out arguments and a lot of in arguments.

copies the implementation of plpar_hcall().

---
 arch/powerpc/platforms/powernv/Makefile |  1 +
 arch/powerpc/platforms/powernv/uvCall.S | 41 +++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 arch/powerpc/platforms/powernv/uvCall.S
arch/powerpc/platforms/powernv/Makefile +1 -0
index b540ce8e..5ae1df02 100644
@@ -4,6 +4,7 @@ obj-y			+= opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
 obj-y			+= rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o
 obj-y			+= opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
 obj-y			+= opal-kmsg.o opal-powercap.o opal-psr.o opal-sensor-groups.o
+obj-y			+= uvCall.o
 
 obj-$(CONFIG_SMP)	+= smp.o subcore.o subcore-asm.o
 obj-$(CONFIG_PCI)	+= pci.o pci-ioda.o npu-dma.o pci-ioda-tce.o
arch/powerpc/platforms/powernv/uvCall.S new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 10 lines · Ram Pai

plpar_ucall() function can now be used to make ucalls with varied number of in and out arguments. It handles 4 out arguments and a lot of in arguments.

copies the implementation of plpar_hcall().

---
 arch/powerpc/platforms/powernv/Makefile |  1 +
 arch/powerpc/platforms/powernv/uvCall.S | 41 +++++++++++++++++++++++++++++++++

I don't think arch/powerpc/platforms/powernv is the right place for this, since we will also need to do ucalls from a secure guest and its kernel may not have CONFIG_PPC_POWERNV=y. Also, the "plpar_" prefix gives rise to a cognitive dissonance, because "plpar" is short for pSeries logical partition, and we definitely are not in a pSeries logical partition here.

Quoted 17 lines
arch/powerpc/platforms/powernv/uvCall.S new file +17 -0
+_GLOBAL_TOC(plpar_ucall)
+
+	mfcr	r0
+	stw	r0,8(r1)
+	mr	r0,r3
+
+	std     r4,STK_PARAM(R4)(r1)     /* Save ret buffer */
+
+	mr	r3,r5
+	mr	r4,r6
+	mr	r5,r7
+	mr	r6,r8
+	mr	r7,r9
+	mr	r8,r10
+
+	sc 2				/* invoke the ultravisor */
+

arch/powerpc/platforms/powernv/uvCall.S line 41

Quoted 10 lines
arch/powerpc/platforms/powernv/uvCall.S new file +10 -0
+	ld	r12,STK_PARAM(R4)(r1)
+	std	r4,  0(r12)
+	std	r5,  8(r12)
+	std	r6, 16(r12)
+	std	r7, 24(r12)
+
+	lwz	r0,8(r1)
+	mtcrf	0xff,r0
+
+	blr				/* return r3 = status */

So we save/restore CR across the ucall, but not LR. Do we really not trust the ultravisor to preserve the non-volatile CR fields, or is it just that you were copying plpar_hcall()? Either way it deserves a note in the patch description.

Paul.