From nobody Tue Nov 11 12:50:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1563586209; cv=none; d=zoho.com; s=zohoarc; b=nTN0ZLqnuDiX6eRXQBwZntxg8sAG9kt9+Z/xlMh6TvBnnjeiLhxoGYeecNzkMOhrk7EXShHv0Yz/t5rMoxnBuz0J4F7npedOMYLnz2RBmcppP450QuQcdVuC9je1XgmZ9m18TfU3+IFN+SljRNFwYXpcB9nIMw9JhsEAz0kdmxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563586209; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=V3MbdJlGq7FJAcpQiDhNO3E31aQ8A12o/jjTmcfBtCo=; b=mgX8T192hFkCDG+bRITHwbeUcq2lJtE9Z00MJn9XIOjikIB3lEauXQxSBYB1jH/DSdzdwPRHqXAOhLlHonKpfhTxerERkTtLXLDYsA4ZIb46VWcPkHpsbM5ovuLgR1r5Yfr5tqVGzlaE0x1pdjR2EJYDfg4FQxcx7NbfJSPVYns= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563586209781730.4226804721029; Fri, 19 Jul 2019 18:30:09 -0700 (PDT) Received: from localhost ([::1]:49130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeCO-0003Qw-QO for importer@patchew.org; Fri, 19 Jul 2019 21:30:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43973) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeBo-00010o-6r for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoeBn-0003Xu-43 for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:32 -0400 Received: from ozlabs.ru ([107.173.13.209]:59116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hoeBm-0003XN-TR; Fri, 19 Jul 2019 21:29:31 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 7CF3AAE807E6; Fri, 19 Jul 2019 21:28:53 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Sat, 20 Jul 2019 11:28:47 +1000 Message-Id: <20190720012850.14369-2-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190720012850.14369-1-aik@ozlabs.ru> References: <20190720012850.14369-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu RFC 1/4] spapr: Allow changing kernel loading address X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Mackerras , Michael Ellerman , qemu-ppc@nongnu.org, Alexey Kardashevskiy , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Useful for the debugging purposes. Signed-off-by: Alexey Kardashevskiy --- include/hw/ppc/spapr.h | 1 + hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 74e427b588fc..ff82bb8554e1 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -159,6 +159,7 @@ struct SpaprMachineState { void *fdt_blob; long kernel_size; bool kernel_le; + uint64_t kernel_addr; uint32_t initrd_base; long initrd_size; uint64_t rtc_offset; /* Now used only during incoming migration */ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 7fad42350538..6d13d65d8996 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1179,7 +1179,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,= void *fdt) spapr->initrd_base + spapr->initrd_size)); =20 if (spapr->kernel_size) { - uint64_t kprop[2] =3D { cpu_to_be64(KERNEL_LOAD_ADDR), + uint64_t kprop[2] =3D { cpu_to_be64(spapr->kernel_addr), cpu_to_be64(spapr->kernel_size) }; =20 _FDT(fdt_setprop(fdt, chosen, "qemu,boot-kernel", @@ -1365,7 +1365,7 @@ static void *spapr_build_fdt(SpaprMachineState *spapr) =20 /* Build memory reserve map */ if (spapr->kernel_size) { - _FDT((fdt_add_mem_rsv(fdt, KERNEL_LOAD_ADDR, spapr->kernel_size))); + _FDT((fdt_add_mem_rsv(fdt, spapr->kernel_addr, spapr->kernel_size)= )); } if (spapr->initrd_size) { _FDT((fdt_add_mem_rsv(fdt, spapr->initrd_base, spapr->initrd_size)= )); @@ -1391,7 +1391,8 @@ static void *spapr_build_fdt(SpaprMachineState *spapr) =20 static uint64_t translate_kernel_address(void *opaque, uint64_t addr) { - return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; + SpaprMachineState *spapr =3D opaque; + return (addr & 0x0fffffff) + spapr->kernel_addr; } =20 static void emulate_spapr_hypercall(PPCVirtualHypervisor *vhyp, @@ -2995,12 +2996,12 @@ static void spapr_machine_init(MachineState *machin= e) uint64_t lowaddr =3D 0; =20 spapr->kernel_size =3D load_elf(kernel_filename, NULL, - translate_kernel_address, NULL, + translate_kernel_address, spapr, NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0, 0); if (spapr->kernel_size =3D=3D ELF_LOAD_WRONG_ENDIAN) { spapr->kernel_size =3D load_elf(kernel_filename, NULL, - translate_kernel_address, NULL, = NULL, + translate_kernel_address, spapr,= NULL, &lowaddr, NULL, 0, PPC_ELF_MACHI= NE, 0, 0); spapr->kernel_le =3D spapr->kernel_size > 0; @@ -3016,7 +3017,7 @@ static void spapr_machine_init(MachineState *machine) /* Try to locate the initrd in the gap between the kernel * and the firmware. Add a bit of space just in case */ - spapr->initrd_base =3D (KERNEL_LOAD_ADDR + spapr->kernel_size + spapr->initrd_base =3D (spapr->kernel_addr + spapr->kernel_size + 0x1ffff) & ~0xffff; spapr->initrd_size =3D load_image_targphys(initrd_filename, spapr->initrd_base, @@ -3253,6 +3254,18 @@ static void spapr_set_vsmt(Object *obj, Visitor *v, = const char *name, visit_type_uint32(v, name, (uint32_t *)opaque, errp); } =20 +static void spapr_get_kernel_addr(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + visit_type_uint64(v, name, (uint64_t *)opaque, errp); +} + +static void spapr_set_kernel_addr(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + visit_type_uint64(v, name, (uint64_t *)opaque, errp); +} + static char *spapr_get_ic_mode(Object *obj, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); @@ -3358,6 +3371,14 @@ static void spapr_instance_init(Object *obj) object_property_add_bool(obj, "vfio-no-msix-emulation", spapr_get_msix_emulation, NULL, NULL); =20 + object_property_add(obj, "kernel-addr", "uint64", spapr_get_kernel_add= r, + spapr_set_kernel_addr, NULL, &spapr->kernel_addr, + &error_abort); + object_property_set_description(obj, "kernel-addr", + stringify(KERNEL_LOAD_ADDR) + " for -kernel is the default", + NULL); + spapr->kernel_addr =3D KERNEL_LOAD_ADDR; /* The machine class defines the default interrupt controller mode */ spapr->irq =3D smc->irq; object_property_add_str(obj, "ic-mode", spapr_get_ic_mode, --=20 2.17.1 From nobody Tue Nov 11 12:50:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1563586197; cv=none; d=zoho.com; s=zohoarc; b=MWyPtiyJygmDKc916ywNVY+iZtOyq9llwY/ZtTdRgXXevw6x5qDeHRmmZKk4bQulHWTrX/XTMCge6ztZN4Ak18xHxP8D7y3n0hbyh/iKdcXO7vf+dfEmkt/3EPLz0G3Tfo6yP/XOvAdUhnSeUA7i4h7KF7uv0XiqX9pRqusKhLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563586197; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mCPqif/bcqwz+T6ndtCnvgUlWqpeBws248b4I04hpM8=; b=XbjcDuI9lywtR+G45NTRADCxBy6q9yur04VXSNK8ImqLdMNb0Opxt+bORYHjcL795t00lxsHes0CqyC7k6YXiPcUMCoe/43A8YgiFXlDE9IvuTFlDPZSvV7PvFyBQHGRs31J837jSAyiFQCkClcBtU9RrsPSWHz30RZzih7Tjj0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563586197018985.3405243804149; Fri, 19 Jul 2019 18:29:57 -0700 (PDT) Received: from localhost ([::1]:49114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeCB-0002Ss-Rb for importer@patchew.org; Fri, 19 Jul 2019 21:29:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43998) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeBq-0001BQ-HW for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoeBp-0003Yk-A6 for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:34 -0400 Received: from ozlabs.ru ([107.173.13.209]:59138) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hoeBp-0003Yb-2b; Fri, 19 Jul 2019 21:29:33 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id A4BBEAE807F2; Fri, 19 Jul 2019 21:28:55 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Sat, 20 Jul 2019 11:28:48 +1000 Message-Id: <20190720012850.14369-3-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190720012850.14369-1-aik@ozlabs.ru> References: <20190720012850.14369-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu RFC 2/4] spapr: Allow bios-less configuration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Mackerras , Michael Ellerman , qemu-ppc@nongnu.org, Alexey Kardashevskiy , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The pseries kernel can do either usual prom-init boot or kexec style boot. We always did the prom-init which relies on the completeness of the device tree (for example, PCI BARs have to be assigned beforehand) and the client interface; the system firmware (SLOF) implements this. However we can use the kexec style boot as well. To do that, we can skip loading SLOF and jump straight to the kernel. GPR5=3D=3D0 (the client interface entry point, SLOF passes a valid pointer there) tells Linux to do the kexec boot rather than prom_init so it can proceed to the initramfs. With few PCI fixes in the guest kernel, it can boot from PCI (via petitboot, for example). This adds a "bios" machine option which controls whether QEMU loads SLOF or jumps directly to the kernel. When bios=3D=3Doff, this does not copy SLOF and RTAS into the guest RAM and sets RTAS properties to 0 to bypass the kexec user space tool which checks for their presence (not for the values though). Signed-off-by: Alexey Kardashevskiy --- include/hw/ppc/spapr.h | 1 + hw/ppc/spapr.c | 58 ++++++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index ff82bb8554e1..7f5d7a70d27e 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -160,6 +160,7 @@ struct SpaprMachineState { long kernel_size; bool kernel_le; uint64_t kernel_addr; + bool bios_enabled; uint32_t initrd_base; long initrd_size; uint64_t rtc_offset; /* Now used only during incoming migration */ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6d13d65d8996..81ad6a6f28de 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1116,6 +1116,10 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, = void *fdt) _FDT(fdt_setprop(fdt, rtas, "ibm,lrdr-capacity", lrdr_capacity, sizeof(lrdr_capacity))); =20 + /* These are to make kexec-lite happy */ + _FDT(fdt_setprop_cell(fdt, rtas, "linux,rtas-base", 0)); + _FDT(fdt_setprop_cell(fdt, rtas, "rtas-size", 0)); + spapr_dt_rtas_tokens(fdt, rtas); } =20 @@ -1814,7 +1818,11 @@ static void spapr_machine_reset(MachineState *machin= e) spapr->fdt_blob =3D fdt; =20 /* Set up the entry state */ - spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT, fdt_addr); + if (!spapr->bios_enabled) { + spapr_cpu_set_entry_state(first_ppc_cpu, spapr->kernel_addr, fdt_a= ddr); + } else { + spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT, fdt_ad= dr); + } first_ppc_cpu->env.gpr[5] =3D 0; =20 spapr->cas_reboot =3D false; @@ -3031,20 +3039,22 @@ static void spapr_machine_init(MachineState *machin= e) } } =20 - if (bios_name =3D=3D NULL) { - bios_name =3D FW_FILE_NAME; + if (spapr->bios_enabled) { + if (bios_name =3D=3D NULL) { + bios_name =3D FW_FILE_NAME; + } + filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!filename) { + error_report("Could not find LPAR firmware '%s'", bios_name); + exit(1); + } + fw_size =3D load_image_targphys(filename, 0, FW_MAX_SIZE); + if (fw_size <=3D 0) { + error_report("Could not load LPAR firmware '%s'", filename); + exit(1); + } + g_free(filename); } - filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); - if (!filename) { - error_report("Could not find LPAR firmware '%s'", bios_name); - exit(1); - } - fw_size =3D load_image_targphys(filename, 0, FW_MAX_SIZE); - if (fw_size <=3D 0) { - error_report("Could not load LPAR firmware '%s'", filename); - exit(1); - } - g_free(filename); =20 /* FIXME: Should register things through the MachineState's qdev * interface, this is a legacy from the sPAPREnvironment structure @@ -3266,6 +3276,20 @@ static void spapr_set_kernel_addr(Object *obj, Visit= or *v, const char *name, visit_type_uint64(v, name, (uint64_t *)opaque, errp); } =20 +static bool spapr_get_bios_enabled(Object *obj, Error **errp) +{ + SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); + + return spapr->bios_enabled; +} + +static void spapr_set_bios_enabled(Object *obj, bool value, Error **errp) +{ + SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); + + spapr->bios_enabled =3D value; +} + static char *spapr_get_ic_mode(Object *obj, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); @@ -3379,6 +3403,12 @@ static void spapr_instance_init(Object *obj) " for -kernel is the default", NULL); spapr->kernel_addr =3D KERNEL_LOAD_ADDR; + object_property_add_bool(obj, "bios", spapr_get_bios_enabled, + spapr_set_bios_enabled, NULL); + object_property_set_description(obj, "bios", "Conrols whether to load = bios", + NULL); + spapr->bios_enabled =3D true; + /* The machine class defines the default interrupt controller mode */ spapr->irq =3D smc->irq; object_property_add_str(obj, "ic-mode", spapr_get_ic_mode, --=20 2.17.1 From nobody Tue Nov 11 12:50:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1563586168; cv=none; d=zoho.com; s=zohoarc; b=ErBZYWeH9Vvio/pxZa59Jf5nc3PkbIdgnRweWcPB1IBnPLUEiEUFSe0Ce7msNjngzVPAPCNrJqaoOG9aMP2UFFj6KUBBe6RWBR+VjfzS68hOyM8X2UAUKmrN2oLg3H0MsR5aUhKNNDRWjoVwazMqkSDY8rz9XV2q7/p2ysW0+NQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563586168; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=utBHYjKYlJ4ebKMrklFSJVjcasyRt/MP69BNAkPWr64=; b=DxVItfyQd2vv+miTWh9jet7d2Sf9rmjvnU6zTAqMAC+o7GHNJWFqoX8JwQj/ZmSrhMdRanGJ2paRmPlV8/DTcDrtmhxo34OzcLh27Iip2b9Kl+bBj/qjx7lmPye9sUz/3+xpBjySbnhmtgxVpF7nHtbwApSCgUj99N0HbGvP0ks= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563586168288493.06423092438956; Fri, 19 Jul 2019 18:29:28 -0700 (PDT) Received: from localhost ([::1]:49098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeBb-0000WF-KA for importer@patchew.org; Fri, 19 Jul 2019 21:29:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43842) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeBQ-0008T2-Of for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoeBP-0003EX-MC for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:08 -0400 Received: from ozlabs.ru ([107.173.13.209]:59038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hoeBP-0003A2-HN; Fri, 19 Jul 2019 21:29:07 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id CF18EAE807F3; Fri, 19 Jul 2019 21:28:57 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Sat, 20 Jul 2019 11:28:49 +1000 Message-Id: <20190720012850.14369-4-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190720012850.14369-1-aik@ozlabs.ru> References: <20190720012850.14369-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu RFC 3/4] spapr: Advertise H_RTAS to the guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Mackerras , Michael Ellerman , qemu-ppc@nongnu.org, Alexey Kardashevskiy , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since day 1 QEMU implemented RTAS as a custom hypercall wrapped into a small 20 bytes blob which guest would call to enter RTAS. Although it works fine, it is still a separate binary image which requires signing at no additional benefit. This adds a flag into /chosen to tell a modified guest that if the flag is there, it can call H_RTAS directly and avoid calling into the RTAS blob. Signed-off-by: Alexey Kardashevskiy --- hw/ppc/spapr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 81ad6a6f28de..b097a99951f1 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1230,6 +1230,9 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,= void *fdt) _FDT(fdt_setprop_cell(fdt, chosen, "linux,pci-probe-only", 0)); } =20 + /* We always implemented RTAS as hcall, tell guests to call it directl= y */ + _FDT(fdt_setprop_cell(fdt, chosen, "qemu,h_rtas", 1)); + spapr_dt_ov5_platform_support(spapr, fdt, chosen); =20 g_free(stdout_path); --=20 2.17.1 From nobody Tue Nov 11 12:50:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1563586224; cv=none; d=zoho.com; s=zohoarc; b=NtV60MZALqWZK/N7ymWVP4Lv4eR0cOr6Le2YZMdDfVhzysJlLKKPZBA2VxkbeftEIW8/LTlzJM9visxravygNzK9t6tNocu9uD/7s0tl+a7zlSIALflN9WPEDhzOmP/zt9lWzcMe6OvYo/UZ5YNF7n7AkATg5707QRUQixlFeZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563586224; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6TpkIkNh0DTv+dm84yewllY1gTqasu2GUD4Tk1nYLrU=; b=I+1inLRN0eLl1p3reCZWTLcM1qQBZR3drkCSugLcams0YZ/mhJ3IZkdVwcC629h4sFa6V4zFkBqhEZ2wWvvskEro33KR+55bnbcWcuA3dK9ssxo7kCycOHluzGe+NMY1EB9urtmGSAjsT7LLMymXZgQBI9G4kq8Lc89zX4tCD8I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156358622413456.358578975522846; Fri, 19 Jul 2019 18:30:24 -0700 (PDT) Received: from localhost ([::1]:49136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeCd-0004O5-2u for importer@patchew.org; Fri, 19 Jul 2019 21:30:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44029) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeBv-0001WL-1Z for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoeBt-0003ay-Nv for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:29:38 -0400 Received: from ozlabs.ru ([107.173.13.209]:59146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hoeBt-0003ar-FS; Fri, 19 Jul 2019 21:29:37 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 0A804AE807F4; Fri, 19 Jul 2019 21:28:59 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Sat, 20 Jul 2019 11:28:50 +1000 Message-Id: <20190720012850.14369-5-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190720012850.14369-1-aik@ozlabs.ru> References: <20190720012850.14369-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu RFC 4/4] spapr: Implement SLOF-less client_architecture_support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Mackerras , Michael Ellerman , qemu-ppc@nongnu.org, Alexey Kardashevskiy , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" QEMU already implements H_CAS called by SLOF. The existing handler prepares a diff FDT and SLOF applies it on top of its current tree. In SLOF-less setup when the user explicitly selected "bios=3Dno", this updates the FDT from the OS, updates it and writes back to the OS. The new behavior is advertised to the OS via "/chosen/qemu,h_cas". Signed-off-by: Alexey Kardashevskiy --- include/hw/ppc/spapr.h | 5 +++++ hw/ppc/spapr.c | 24 ++++++++++++++++----- hw/ppc/spapr_hcall.c | 49 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 7f5d7a70d27e..73cd9cf25b83 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -766,9 +766,14 @@ struct SpaprEventLogEntry { =20 void spapr_events_init(SpaprMachineState *sm); void spapr_dt_events(SpaprMachineState *sm, void *fdt); +int spapr_h_cas_do_compose_response(SpaprMachineState *spapr, void *fdt, + SpaprOptionVector *ov5_updates); int spapr_h_cas_compose_response(SpaprMachineState *sm, target_ulong addr, target_ulong size, SpaprOptionVector *ov5_updates); +#define FDT_MAX_SIZE 0x100000 +void *spapr_build_fdt(SpaprMachineState *spapr); + void close_htab_fd(SpaprMachineState *spapr); void spapr_setup_hpt_and_vrma(SpaprMachineState *spapr); void spapr_free_hpt(SpaprMachineState *spapr); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b097a99951f1..f84895f4a8b4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -978,6 +978,19 @@ static bool spapr_hotplugged_dev_before_cas(void) return false; } =20 +int spapr_h_cas_do_compose_response(SpaprMachineState *spapr, void *fdt, + SpaprOptionVector *ov5_updates) +{ + /* Fixup cpu nodes */ + _FDT((spapr_fixup_cpu_dt(fdt, spapr))); + + if (spapr_dt_cas_updates(spapr, fdt, ov5_updates)) { + return -1; + } + + return 0; +} + int spapr_h_cas_compose_response(SpaprMachineState *spapr, target_ulong addr, target_ulong size, SpaprOptionVector *ov5_updates) @@ -1009,10 +1022,7 @@ int spapr_h_cas_compose_response(SpaprMachineState *= spapr, _FDT((fdt_open_into(fdt_skel, fdt, size))); g_free(fdt_skel); =20 - /* Fixup cpu nodes */ - _FDT((spapr_fixup_cpu_dt(fdt, spapr))); - - if (spapr_dt_cas_updates(spapr, fdt, ov5_updates)) { + if (spapr_h_cas_do_compose_response(spapr, fdt, ov5_updates)) { return -1; } =20 @@ -1232,6 +1242,10 @@ static void spapr_dt_chosen(SpaprMachineState *spapr= , void *fdt) =20 /* We always implemented RTAS as hcall, tell guests to call it directl= y */ _FDT(fdt_setprop_cell(fdt, chosen, "qemu,h_rtas", 1)); + /* Tell the guest that H_CAS will return the entire FDT now, not the d= iff */ + if (!spapr->bios_enabled) { + _FDT(fdt_setprop_cell(fdt, chosen, "qemu,h_cas", 1)); + } =20 spapr_dt_ov5_platform_support(spapr, fdt, chosen); =20 @@ -1262,7 +1276,7 @@ static void spapr_dt_hypervisor(SpaprMachineState *sp= apr, void *fdt) } } =20 -static void *spapr_build_fdt(SpaprMachineState *spapr) +void *spapr_build_fdt(SpaprMachineState *spapr) { MachineState *machine =3D MACHINE(spapr); MachineClass *mc =3D MACHINE_GET_CLASS(machine); diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index b964d94f330b..c5cb06c9d507 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -17,6 +17,7 @@ #include "hw/ppc/spapr_ovec.h" #include "mmu-book3s-v3.h" #include "hw/mem/memory-device.h" +#include "sysemu/device_tree.h" =20 static bool has_spr(PowerPCCPU *cpu, int spr) { @@ -1774,9 +1775,51 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu, /* legacy hash or new hash: */ spapr_setup_hpt_and_vrma(spapr); } - spapr->cas_reboot =3D - (spapr_h_cas_compose_response(spapr, args[1], args[2], - ov5_updates) !=3D 0); + + if (spapr->bios_enabled) { + spapr->cas_reboot =3D + (spapr_h_cas_compose_response(spapr, args[1], args[2], + ov5_updates) !=3D 0); + } else { + int size; + void *fdt, *fdt_skel; + struct fdt_header hdr =3D { 0 }; + + cpu_physical_memory_read(args[1], &hdr, sizeof(hdr)); + size =3D fdt32_to_cpu(hdr.totalsize); + if (size > FDT_MAX_SIZE) { + return H_NOT_AVAILABLE; + } + + fdt_skel =3D g_malloc0(size); + cpu_physical_memory_read(args[1], fdt_skel, size); + + fdt =3D g_malloc0(FDT_MAX_SIZE); + fdt_open_into(fdt_skel, fdt, FDT_MAX_SIZE); + g_free(fdt_skel); + + if (spapr_h_cas_do_compose_response(spapr, fdt, ov5_updates)) { + g_free(fdt); + return H_NOT_AVAILABLE; + } + fdt_pack(fdt); + if (fdt_totalsize(fdt) > FDT_MAX_SIZE) { + error_report("FDT too big ! 0x%x bytes (max is 0x%x)", + fdt_totalsize(fdt), FDT_MAX_SIZE); + g_free(fdt); + return H_NOT_AVAILABLE; + } + + /* Load the fdt */ + cpu_physical_memory_write(args[1], fdt, fdt_totalsize(fdt)); + + g_free(spapr->fdt_blob); + spapr->fdt_size =3D fdt_totalsize(fdt); + spapr->fdt_initial_size =3D spapr->fdt_size; + spapr->fdt_blob =3D fdt; + + qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); + } } =20 /* --=20 2.17.1