From nobody Thu May 16 05:37:03 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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=1555390639; cv=none; d=zoho.com; s=zohoarc; b=CZ6b7LOc1ajTkdIkfmEcwIKNCve9HxLmwlYtsQWng+KP0+/YjiOYbFgYqTA9G1Ef1VBCEUeVwnrEYTj3WCjuUR1Q1N9jAzpIvskHpALu9PeSvGOWODxjYRlbuldapYDQPoJhUx2xNMTt/J/Csxzx9ovGA/M0xwOFL3Icq5rue+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555390639; 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=LMMn1/3yoW4kcpAOUmvJsGSodCeWg/DkFUqZPl9PJHI=; b=lWUwRub48i0vteRRfPVYURlfGKZj/JI8fdWKM+gCLn3X98uNphaQHBy4oPsOyp95555h9CQsvs4lueKU8A4t97GoWGxjaCgtQjezcOIGHAq1QychBBzuqM/QOo2+EO8niAVLSKQ6nyHO6yopm8NsH6VscmkcZPgju22ChlTdSxA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555390639083444.1940852409491; Mon, 15 Apr 2019 21:57:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:59362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGG9V-0003e8-8W for importer@patchew.org; Tue, 16 Apr 2019 00:57:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGG8d-0003HX-HN for qemu-devel@nongnu.org; Tue, 16 Apr 2019 00:56:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGG8c-0006IO-F4 for qemu-devel@nongnu.org; Tue, 16 Apr 2019 00:56:07 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:37326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hGG8a-0006HG-29; Tue, 16 Apr 2019 00:56:04 -0400 Received: by mail-pl1-x642.google.com with SMTP id w23so9696839ply.4; Mon, 15 Apr 2019 21:56:03 -0700 (PDT) Received: from bobo.local0.net (61-68-62-84.tpgi.com.au. [61.68.62.84]) by smtp.gmail.com with ESMTPSA id v82sm114487487pfa.170.2019.04.15.21.55.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Apr 2019 21:56:02 -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=LMMn1/3yoW4kcpAOUmvJsGSodCeWg/DkFUqZPl9PJHI=; b=sI00WmPAY+bgQFfE5Kr+QVwcuMjlgCg1LwntdHMjHUJRUmKWY8Ds5UFoU2lpsRgc40 GMGZer+URf01N+jmJN2J1jbVEwT1hLyNZc6J9cKWaJIgiDFsP8iL6WbGpBzvRPJjQTrC gQ8NTj9/C2PFNXYvpe5tyKL05IXBj0sSx8VGEqwSsChDjZq921V2IZ529aK+ESBWwOtw bcOtUXfZTwo73u6FH/i9hRId5suEvfPhxt00tIQ296+InFb9CrXPY3Q7C+VDlxcoxmyI vkj8dguvpr7XQSlyg7EqkR0aSW1H3DRAYWzfSfd0QM0QVYt+TECtCdUR4XiLzLwx6Idj Qoww== 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=LMMn1/3yoW4kcpAOUmvJsGSodCeWg/DkFUqZPl9PJHI=; b=jzbvToCGFMH+6nHoOhmxMwoLXxOnvHC45EEbPa7QcTirP5+Q9kuk9dS/+V4YTwMOR4 GZnD0EzCoSWU+y96Ml7Uif/n/ozfeQXwPdbUlytMSYaK8BdxmklPa40VtzILek1afFxy iFEVR8Zq7a4Hxxz1EhZnjylB39hVq4uRY7iAY40Y3u5ouV8vm0kPZdoe7i+XCv0e+AwN 1/k8bLhVbUh6CS/VJRjj48Gxmby1hbl6GQbXAsHSEt0CZfqAYMolN/7YvRexyHq5XNMp us5Aojj/DXP1CE9rW3h3udi9wr8qy++p+/iYQbauKZ79wkxSHnZ1vwA5vSlsVHetUcaz cweA== X-Gm-Message-State: APjAAAWlMbbjYbXMIL3VwMlMCfrihlib6jZ566Msf5N3stx1/LTsQckX jP7EAV1x5MRNx+TIw2KIX5c= X-Google-Smtp-Source: APXvYqyEMx6WqHoRWNdUf/raCkPPTn2rw9w4m/QCn8dZNWOxs1tgvoZJqTuTOMCNTMwWCfkzhKrsiw== X-Received: by 2002:a17:902:e704:: with SMTP id co4mr39271996plb.30.1555390563111; Mon, 15 Apr 2019 21:56:03 -0700 (PDT) From: Nicholas Piggin To: David Gibson Date: Tue, 16 Apr 2019 14:55:52 +1000 Message-Id: <20190416045552.24573-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::642 Subject: [Qemu-devel] [PATCH v3] spapr: add splpar hcalls 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 --- v3: Removed wrong comment about GPR3, drop H_JOIN for now (at least until it is tested some more in Linux/KVM), and expand the comment about not prod bit. hw/ppc/spapr_hcall.c | 71 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 8a736797b9..8892ad008b 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1065,6 +1065,74 @@ static target_ulong h_cede(PowerPCCPU *cpu, SpaprMac= hineState *spapr, return H_SUCCESS; } =20 +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; + } + + /* + * PAPR calls for waiting until proded in this case (or presumably + * an external interrupt if MSR[EE]=3D1, without dispatch sequence cou= nt + * check. + */ + if (cpu =3D=3D spapr_find_cpu(target)) { + cs->halted =3D 1; + cs->exception_index =3D EXCP_HALTED; + cs->exit_request =3D 1; + + return H_SUCCESS; + } + + /* + * 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; +} + +static target_ulong h_prod(PowerPCCPU *cpu, SpaprMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + target_long target =3D args[0]; + CPUState *cs; + + /* + * PAPR specifies there should be a prod flag should be associated with + * a vCPU, which gets set here, tested by H_CEDE, and cleared any time + * the vCPU is dispatched, including via preemption. + * + * We don't implement this because it is not used by Linux. The bit wo= uld + * be difficult or impossible to use properly because preemption can n= ot + * be prevented so dispatch sequence count would have to somehow be us= ed + * to detect it. + */ + + 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 +1928,9 @@ 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_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