From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb1ro-0001uP-Im for qemu-devel@nongnu.org; Mon, 06 Oct 2014 02:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xb1rX-0002RN-Nn for qemu-devel@nongnu.org; Mon, 06 Oct 2014 02:33:56 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:57216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb1rX-0002Qp-KZ for qemu-devel@nongnu.org; Mon, 06 Oct 2014 02:33:39 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Oct 2014 02:33:37 -0400 Message-ID: <54323782.8060804@linux.vnet.ibm.com> Date: Mon, 06 Oct 2014 12:02:34 +0530 From: Aravinda Prasad MIME-Version: 1.0 References: <20140825134353.2361.52046.stgit@aravindap> <20140825134545.2361.66860.stgit@aravindap> <540CC44F.8060804@suse.de> In-Reply-To: <540CC44F.8060804@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/5] target-ppc: Handle ibm, nmi-register RTAS call List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: benh@au1.ibm.com, aik@au1.ibm.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, paulus@samba.org On Monday 08 September 2014 02:17 AM, Alexander Graf wrote: > > > On 25.08.14 15:45, Aravinda Prasad wrote: >> This patch adds FWNMI support in qemu for powerKVM >> guests by handling the ibm,nmi-register rtas call. >> Whenever OS issues ibm,nmi-register RTAS call, the >> machine check notification address is saved and the >> machine check interrupt vector 0x200 is patched to >> issue a private hcall. >> >> Signed-off-by: Aravinda Prasad >> --- >> hw/ppc/spapr_rtas.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ >> include/hw/ppc/spapr.h | 8 ++++ >> 2 files changed, 98 insertions(+), 1 deletion(-) >> >> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c >> index 02ddbf9..1135d2b 100644 >> --- a/hw/ppc/spapr_rtas.c >> +++ b/hw/ppc/spapr_rtas.c >> @@ -277,6 +277,91 @@ static void rtas_ibm_set_system_parameter(PowerPCCPU *cpu, >> rtas_st(rets, 0, ret); >> } >> >> +static void rtas_ibm_nmi_register(PowerPCCPU *cpu, >> + sPAPREnvironment *spapr, >> + uint32_t token, uint32_t nargs, >> + target_ulong args, >> + uint32_t nret, target_ulong rets) >> +{ >> + int i; >> + uint32_t branch_inst = 0x48000002; >> + target_ulong guest_machine_check_addr; >> + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); >> + /* >> + * Trampoline saves r3 in sprg2 and issues private hcall >> + * to request qemu to build error log. QEMU builds the >> + * error log, copies to rtas-blob and returns the address. >> + * The initial 16 bytes in rtas-blob consists of saved srr0 >> + * and srr1 which we restore and pass on the actual error >> + * log address to OS handled mcachine check notification >> + * routine >> + */ >> + uint32_t trampoline[] = { >> + 0x7c7243a6, /* mtspr SPRN_SPRG2,r3 */ >> + 0x38600000, /* li r3,0 */ >> + /* 0xf004 is the KVMPPC_H_REPORT_ERR private HCALL */ >> + 0x6063f004, /* ori r3,r3,f004 */ >> + /* Issue H_CALL */ >> + 0x44000022, /* sc 1 */ >> + 0x7c9243a6, /* mtspr r4 sprg2 */ >> + 0xe8830000, /* ld r4, 0(r3) */ >> + 0x7c9a03a6, /* mtspr r4, srr0 */ >> + 0xe8830008, /* ld r4, 8(r3) */ >> + 0x7c9b03a6, /* mtspr r4, srr1 */ >> + 0x38630010, /* addi r3,r3,16 */ >> + 0x7c9242a6, /* mfspr r4 sprg2 */ >> + 0x48000002, /* Branch to address registered >> + * by OS. The branch address is >> + * patched below */ >> + 0x48000000, /* b . */ > > So how about we just completely change the layout of the RTAS blob? > > Imagine something like the following (completely untested): > > ---- > > /**** index table ****/ > .long rtas_entry > .long nmi_register > .long nmi_register_final_branch > .long nmi_data > > /**** RTAS handling code ****/ > .align 1024 > rtas_entry: > ... > nmi_register: > ... > nmi_register_final_branch: > ba . > > /**** RTAS data regions ****/ > .align 4096 > nmi_data: > .long 0 > .align 4096 > > ---- > > With this we should be able to have a nice hybrid between easily tunable > asm code and an easy to load and handle blob. Sorry, I was out of office hence could not respond. Yes, even I prefer something like this. BTB, did you intend to have this in spapr-rtas.S? The spapr-rtas.S is compiled into a binary and is read into spapr->rtas_blob. If we want to have rtas-blob layout something similar to above then we may need to link the object file of spapr-rtas.S to QEMU so that the symbols in "index table" and other places could be resolved inside QEMU. If this is fine I will include it in v3. Regards, Aravinda > > > Alex > -- Regards, Aravinda