From nobody Fri Mar 29 13:51:35 2024 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1555047813; cv=none; d=zoho.com; s=zohoarc; b=HLKbTIKOgCdJpmBV7fSQQKPhLe2ee4KCfjaR61JYU8pgW0D8h9InLDw1zBIRbaIbGUU/Oku3t7O4f4eTivy2RvwVdfCdHBNukWHwOwV9EYR506ZmmKP/ifq6YDbLavCq93QA0kxBDHmWKDPyT3zzmyyK6v+OrvZSXgjLR4cQpGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555047813; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=vJm4r0hEPk2pdOBu4EwWQ8tV2fCXs9DtfzB9HdAk1oY=; b=PSklhYkiDsuj/MTRFjASl4Fo260KKvhcvqVifc7ApU0dlPOyyCioqgEq5NIOsBzi4qW/J1vv8S39a2xl2HPdXbHz4wWmKYRc1PU+76yguVHIzER9prcoNyMwRhvz5m4yiS/TtTtOjLszKy+Tu0jYxqUMGEKuKlkdFlK+I0C9CzE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555047813385710.7620184428613; Thu, 11 Apr 2019 22:43:33 -0700 (PDT) Received: from localhost ([127.0.0.1]:59311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEoyB-0001g8-1V for importer@patchew.org; Fri, 12 Apr 2019 01:43:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEoxJ-0001Jb-7b for qemu-devel@nongnu.org; Fri, 12 Apr 2019 01:42:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEoxI-0008S1-47 for qemu-devel@nongnu.org; Fri, 12 Apr 2019 01:42:29 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:34534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hEoxF-00083X-AS; Fri, 12 Apr 2019 01:42:25 -0400 Received: by mail-pg1-x533.google.com with SMTP id v12so4649332pgq.1; Thu, 11 Apr 2019 22:42:25 -0700 (PDT) Received: from bobo.local0.net (115-64-237-195.tpgi.com.au. [115.64.237.195]) by smtp.gmail.com with ESMTPSA id n21sm64237682pfb.42.2019.04.11.22.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 22:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vJm4r0hEPk2pdOBu4EwWQ8tV2fCXs9DtfzB9HdAk1oY=; b=SxlKKcDDnaoRDXpeXMrw755eD1jOlW7wzSyL6CBxd9JpUnmJcuxCaotnU4XB+sDcLh WwrwbK4FCGjHoGwiKcVo/bOmAQQ6HPDyliKKQMXLYd7Z13rTpU67IA/FISFSBktNML59 Xg+ZTgZ4lkfFQrHxBjAV0ak9mJ4sB94x8IECbMuRuRKcWkopLGZ1URmKs6ndZb3R2Uq6 KuB+KJdm5BBc7F+UcuPrB9spSyI72p57dxkDuNQlcdaGlNAdqAqjL256gmEKiqPVM4Vk UvbvdyHDxUYGk7eqyOJKcLjEGRI3bvipGHTuEoehUgvluYxCZ5pNW3bG8VD4DFHLdycY wC3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vJm4r0hEPk2pdOBu4EwWQ8tV2fCXs9DtfzB9HdAk1oY=; b=sqZtK9JYzVc56uWKL4W0Nrum4ES9TQZgBqtVVUHHqCU2iyXe699a0iMTwwb2rnABDu OtjLlLazJ1ZMBLvcRHpd7Ovs0AZV2qNVlvQcKcUUebyn64lAdqKsKhrFBo5133EJkB6L b/A1qMC5LbIRZJUqNQUTy1ALm13UGYrH7lTfw79h4lTM/Ucftl7x1S84LCZxaOC4hSgq ArKhhpReXLrBW25NCjXJ7w+uqJLKO1kx75dY48b+4Xa5UcRKa15Zw2rYV4fnuyRQiiI3 uKrtoXi7fWksSct6ovHZCkwuJEHvqEIW4mYZodHfdhivoT0RZBii8Lcu+i0ptJu02XS9 vHVg== X-Gm-Message-State: APjAAAXf6S4o3vrw7ulA9FcWrZRQqeKj7iA0PAjb/d0gNmx68VJIOksh cmk5fLrujoWymxdd/SBwOcw= X-Google-Smtp-Source: APXvYqyrEZg0YH1En+sjmejnNgFpBondU4SyyTue2dT+Up8Dp3lyJpvwvlTsUbJE+jzPRIF0kjVK+Q== X-Received: by 2002:aa7:8719:: with SMTP id b25mr54387685pfo.90.1555047743944; Thu, 11 Apr 2019 22:42:23 -0700 (PDT) From: Nicholas Piggin To: David Gibson Date: Fri, 12 Apr 2019 15:42:13 +1000 Message-Id: <20190412054214.707-1-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::533 Subject: [Qemu-devel] [PATCH] spapr: add splpar hcalls H_JOIN, H_PROD, H_CONFER X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" These implementations have a few deficiencies that are noted, but are good enough for Linux to use. Signed-off-by: Nicholas Piggin --- This has been tested with TCG with some Linux hacks to use H_JOIN/H_PROD for suspend and CPU unplug (plus an implementation of ibm,suspend-me to do the suspend). Not sure if KVM might need some more work to support H_JOIN properly, but right now Linux only uses it on PowerVM. hw/ppc/spapr_hcall.c | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 8a736797b9..6829cadcd3 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1065,6 +1065,86 @@ static target_ulong h_cede(PowerPCCPU *cpu, SpaprMac= hineState *spapr, return H_SUCCESS; } =20 +static target_ulong h_join(PowerPCCPU *cpu, SpaprMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + CPUPPCState *env =3D &cpu->env; + CPUState *cs =3D CPU(cpu); + + if (env->msr & (1ULL << MSR_EE)) + return H_BAD_MODE; + + /* + * This should check for single-threaded mode. In practice, Linux + * does not try to H_JOIN all CPUs. + */ + + cs->halted =3D 1; + cs->exception_index =3D EXCP_HALTED; + cs->exit_request =3D 1; + + return H_SUCCESS; +} + +static target_ulong h_confer(PowerPCCPU *cpu, SpaprMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + target_long target =3D args[0]; + CPUState *cs =3D CPU(cpu); + + /* + * This does not do a targeted yield or confer, but check the parameter + * anyway. -1 means confer to all/any other CPUs. + */ + if (target !=3D -1 && !CPU(spapr_find_cpu(target))) + return H_PARAMETER; + + /* + * H_CONFER with target =3D=3D this is not exactly the same as H_JOIN + * according to PAPR (e.g., MSR[EE] check and single threaded check + * is not done in this case), but unlikely to matter. + */ + if (cpu =3D=3D spapr_find_cpu(target)) + return h_join(cpu, spapr, opcode, args); + + /* + * This does not implement the dispatch sequence check that PAPR calls= for, + * but PAPR also specifies a stronger implementation where the target = must + * be run (or EE, or H_PROD) before H_CONFER returns. Without such a h= ard + * scheduling requirement implemented, there is no correctness reason = to + * implement the dispatch sequence check. + */ + cs->exception_index =3D EXCP_YIELD; + cpu_loop_exit(cs); + + return H_SUCCESS; +} + +/* + * H_PROD and H_CONFER are specified to only modify GPR r3, which is not + * achievable running under KVM, although KVM already implements H_CONFER + * this way. + */ +static target_ulong h_prod(PowerPCCPU *cpu, SpaprMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + target_long target =3D args[0]; + CPUState *cs; + + /* + * This does not maintain a prod flag for the vCPU that PAPR asks for. + */ + + cs =3D CPU(spapr_find_cpu(target)); + if (!cs) + return H_PARAMETER; + + cs->halted =3D 0; + qemu_cpu_kick(cs); + + return H_SUCCESS; +} + static target_ulong h_rtas(PowerPCCPU *cpu, SpaprMachineState *spapr, target_ulong opcode, target_ulong *args) { @@ -1860,6 +1940,10 @@ static void hypercall_register_types(void) /* hcall-splpar */ spapr_register_hypercall(H_REGISTER_VPA, h_register_vpa); spapr_register_hypercall(H_CEDE, h_cede); + spapr_register_hypercall(H_CONFER, h_confer); + spapr_register_hypercall(H_JOIN, h_join); + spapr_register_hypercall(H_PROD, h_prod); + spapr_register_hypercall(H_SIGNAL_SYS_RESET, h_signal_sys_reset); =20 /* processor register resource access h-calls */ --=20 2.20.1