From nobody Tue Apr 30 05:02:04 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=1563245312; cv=none; d=zoho.com; s=zohoarc; b=miEqUqamPtGTsPKlXSR8naV4q+juvtzKLtrHW4yHYToba7x0s2szNIEwDs8/IzQqnVtmWEDkSIHFSSqMndilVEN5waw/tFXTX5504/AhJfNlpH/T8b2b7mlnV68OPcoRNzmGA75mFPq041lB6OejZv3gvumlUDrsaWDfxWOo524= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563245312; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PzwK4vtv/PDyhfXpJbiQNfSLcteSs1hAR52r+MzvdUY=; b=KEFVYa6lMBfCoRGgdnrS+1laxSa+VwnfOeUWFKsp+KqLExvs8uS/iKUAdEKixAaGH7GySRwMglAxcfeuQF+pHGTyGUK+kOBrHgcrpebzykF6obZFw0RP05Zj5WX1vlhkw9lbZuBtJjm9P+/hpNYB7II4DZP21o4m0FLnpQXbsZ0= 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 1563245312619428.37077909915797; Mon, 15 Jul 2019 19:48:32 -0700 (PDT) Received: from localhost ([::1]:44964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDVy-0003rK-9h for importer@patchew.org; Mon, 15 Jul 2019 22:48:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44275) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDVQ-0002Ao-GC for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:47:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnDVP-0004Tm-4F for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:47:52 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:38216) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnDVM-0004P8-8F; Mon, 15 Jul 2019 22:47:48 -0400 Received: by mail-pg1-x533.google.com with SMTP id z75so8654541pgz.5; Mon, 15 Jul 2019 19:47:44 -0700 (PDT) Received: from bobo.local0.net ([203.220.8.141]) by smtp.gmail.com with ESMTPSA id x8sm16557837pfa.46.2019.07.15.19.47.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 19:47:43 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=PzwK4vtv/PDyhfXpJbiQNfSLcteSs1hAR52r+MzvdUY=; b=Clsy1lqvQ+brPUaCagfqXzIwQJaFkktO9aUTxPdv9UhYJbfFsOdQtX9kioO06xuHVO tIx/VKgzOeCyD0YkYQdlk4x5GAr75YC4evYSM7bZKxJvZlzAzTd9riEKTs9BSayP2agi QOADGyoE+sCxnA6h9TwB+I+Y8ZsLvMIbXUYxiEjdyvdUfUrpTtQqyIu2qX+l/FFrqVMi qmUyWqW0PVb2u+sdksZ2C5DtanuFrrU+G16QtPnorzTn3eWdIBPXTWxCTSbWzmUpbQIT CKw68X3NB1gBjkFazZT27t9EyrHuBt8cYibGxyw0bpdCpd52srVZxANC/hQ2j9xLKGo0 XgAg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=PzwK4vtv/PDyhfXpJbiQNfSLcteSs1hAR52r+MzvdUY=; b=oQSOG2BnWjX2lcNslt3krlBvsdRpX4Q6mQgr55JCW2H+dLR/ikSUPyAyH7RT+aesdg HTULwIMYlPyFR7ZvW5vlXjhfPscrZn+skww8FIQeNww7UXoI/OOYWE2eXsmEKPpEELFe uKOGHfa00q3CsqD2cLpYxd3q2HiDpuHQd4v6vcDXQmh/jpopjS4kyaIFZFN1n1wmd8bK 4tqvzXI1VDVF6F7VAc1CGoyD7McYiVkvXkATGipTGE4Dvvt3odSi1SbEz5++misyicKH t2WFJ61IF1YHPViE6JMUVZTQDjE0CyHXU83XQIwfN88XC7UxGphCIgXy001O8QWcyvb5 RJow== X-Gm-Message-State: APjAAAW1125NhwEvp+D+eX+xYOVuU2kSuN9zF0ZXvjPOvMJjPi77iHpv f1y3p0HWKlUiFUTnUDmSDlA= X-Google-Smtp-Source: APXvYqz4FtsMJsXeoozSjP+Sm7fdcXk32s8SfYRkIKSI8idPKlU0d54sZ+YB/T87XeW3K67tlf33Zw== X-Received: by 2002:a63:5550:: with SMTP id f16mr11661981pgm.426.1563245263688; Mon, 15 Jul 2019 19:47:43 -0700 (PDT) From: Nicholas Piggin To: David Gibson Date: Tue, 16 Jul 2019 12:47:22 +1000 Message-Id: <20190716024726.17864-2-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190716024726.17864-1-npiggin@gmail.com> References: <20190716024726.17864-1-npiggin@gmail.com> 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 v4 1/5] spapr: Implement dispatch counter and prod bit on tcg 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: Greg Kurz , Nicholas Piggin , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, =?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" Implement cpu_exec_enter/exit on ppc which calls into new methods of the same name in PPCVirtualHypervisorClass. These are used by spapr to implement these splpar elements, used in subsequent changes. Signed-off-by: Nicholas Piggin --- hw/ppc/spapr.c | 25 +++++++++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 5 ++++- hw/ppc/spapr_hcall.c | 5 ----- include/hw/ppc/spapr.h | 7 +++++++ include/hw/ppc/spapr_cpu_core.h | 2 ++ target/ppc/cpu.h | 2 ++ target/ppc/translate_init.inc.c | 25 +++++++++++++++++++++++++ 7 files changed, 65 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 821f0d4a49..87b11e2484 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4302,6 +4302,29 @@ PowerPCCPU *spapr_find_cpu(int vcpu_id) return NULL; } =20 +static void spapr_cpu_exec_enter(PPCVirtualHypervisor *vhyp, PowerPCCPU *c= pu) +{ + SpaprCpuState *spapr_cpu =3D spapr_cpu_state(cpu); + + /* These are only called by TCG, KVM maintains dispatch state */ + + spapr_cpu->prod =3D false; + spapr_cpu->dispatch_counter++; + assert((spapr_cpu->dispatch_counter & 1) =3D=3D 0); + if (spapr_cpu->vpa_addr) { + CPUState *cs =3D CPU(cpu); + stl_be_phys(cs->as, spapr_cpu->vpa_addr + VPA_DISPATCH_COUNTER, sp= apr_cpu->dispatch_counter); + } +} + +static void spapr_cpu_exec_exit(PPCVirtualHypervisor *vhyp, PowerPCCPU *cp= u) +{ + SpaprCpuState *spapr_cpu =3D spapr_cpu_state(cpu); + + spapr_cpu->dispatch_counter++; + assert((spapr_cpu->dispatch_counter & 1) =3D=3D 1); +} + static void spapr_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -4358,6 +4381,8 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) vhc->hpte_set_r =3D spapr_hpte_set_r; vhc->get_pate =3D spapr_get_pate; vhc->encode_hpt_for_kvm_pr =3D spapr_encode_hpt_for_kvm_pr; + vhc->cpu_exec_enter =3D spapr_cpu_exec_enter; + vhc->cpu_exec_exit =3D spapr_cpu_exec_exit; xic->ics_get =3D spapr_ics_get; xic->ics_resend =3D spapr_ics_resend; xic->icp_get =3D spapr_icp_get; diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 5621fb9a3d..fb2ed9e95d 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -261,6 +261,7 @@ error: static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp) { SpaprCpuCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(sc); + SpaprCpuState *spapr_cpu; CPUCore *cc =3D CPU_CORE(sc); Object *obj; char *id; @@ -287,7 +288,9 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, = int i, Error **errp) goto err; } =20 - cpu->machine_data =3D g_new0(SpaprCpuState, 1); + spapr_cpu =3D g_new0(SpaprCpuState, 1); + spapr_cpu->dispatch_counter =3D 1; + cpu->machine_data =3D spapr_cpu; =20 object_unref(obj); return cpu; diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 6808d4cda8..e615881ac4 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -874,11 +874,6 @@ unmap_out: #define FLAGS_DEREGISTER_DTL 0x0000c00000000000ULL #define FLAGS_DEREGISTER_SLBSHADOW 0x0000e00000000000ULL =20 -#define VPA_MIN_SIZE 640 -#define VPA_SIZE_OFFSET 0x4 -#define VPA_SHARED_PROC_OFFSET 0x9 -#define VPA_SHARED_PROC_VAL 0x2 - static target_ulong register_vpa(PowerPCCPU *cpu, target_ulong vpa) { CPUState *cs =3D CPU(cpu); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 60553d32c4..5d36eec9d0 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -525,6 +525,13 @@ void spapr_register_hypercall(target_ulong opcode, spa= pr_hcall_fn fn); target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode, target_ulong *args); =20 +/* Virtual Processor Area structure constants */ +#define VPA_MIN_SIZE 640 +#define VPA_SIZE_OFFSET 0x4 +#define VPA_SHARED_PROC_OFFSET 0x9 +#define VPA_SHARED_PROC_VAL 0x2 +#define VPA_DISPATCH_COUNTER 0x100 + /* ibm,set-eeh-option */ #define RTAS_EEH_DISABLE 0 #define RTAS_EEH_ENABLE 1 diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_cor= e.h index f9645a7290..3032dfa7ee 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -46,6 +46,8 @@ typedef struct SpaprCpuState { uint64_t vpa_addr; uint64_t slb_shadow_addr, slb_shadow_size; uint64_t dtl_addr, dtl_size; + uint32_t dispatch_counter; + bool prod; struct ICPState *icp; struct XiveTCTX *tctx; } SpaprCpuState; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index c9beba2a5c..78d6504acb 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1224,6 +1224,8 @@ struct PPCVirtualHypervisorClass { void (*hpte_set_r)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t p= te1); void (*get_pate)(PPCVirtualHypervisor *vhyp, ppc_v3_pate_t *entry); target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp); + void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu); + void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu); }; =20 #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor" diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 86fc8f2e31..58d4a93b23 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10473,6 +10473,28 @@ static bool ppc_cpu_is_big_endian(CPUState *cs) } #endif =20 +static void ppc_cpu_exec_enter(CPUState *cs) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + + if (cpu->vhyp) { + PPCVirtualHypervisorClass *vhc =3D + PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); + vhc->cpu_exec_enter(cpu->vhyp, cpu); + } +} + +static void ppc_cpu_exec_exit(CPUState *cs) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + + if (cpu->vhyp) { + PPCVirtualHypervisorClass *vhc =3D + PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); + vhc->cpu_exec_exit(cpu->vhyp, cpu); + } +} + static void ppc_cpu_instance_init(Object *obj) { PowerPCCPU *cpu =3D POWERPC_CPU(obj); @@ -10624,6 +10646,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->tcg_initialize =3D ppc_translate_init; cc->tlb_fill =3D ppc_cpu_tlb_fill; #endif + cc->cpu_exec_enter =3D ppc_cpu_exec_enter; + cc->cpu_exec_exit =3D ppc_cpu_exec_exit; + cc->disas_set_info =3D ppc_disas_set_info; =20 dc->fw_name =3D "PowerPC,UNKNOWN"; --=20 2.20.1 From nobody Tue Apr 30 05:02:04 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=1563245311; cv=none; d=zoho.com; s=zohoarc; b=SwtjeztPnLVyqHVF+p8d0syCHtvPAhgXQGTv3PZUDNdHJHn5RJxNKR8VgAmeqGtFIHVCx8AtKzHojocfYreNU8QPP95z4GNcDnFhcaQn4IbPpTdrIYWVUANNguc3/2pnNpUZfPPgzGIzUWsO+7ndhx3pj3jpPx/jghhbnJPZhGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563245311; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aspJFmRkiuGl98ZZpfTk4UAxRVGqt3PVQT6yVoIbn6Q=; b=O1AtQkn8uLeYzGqYxzRP55PZ5sMf5+RS+W+pVjSDYEDWa5oYlZgO0bApUEPt7DzQppUQneTpE82/yxbx6tRaRBSGfdFp3ePtHp+o6G1QH0/3srsAU1inDqD8mR8r/X/IFDtpAEKkpxF4bHfVH39VsyT5Wkbk0aiYj5BzY26IgMY= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563245311491397.1853059969636; Mon, 15 Jul 2019 19:48:31 -0700 (PDT) Received: from localhost ([::1]:44962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDVx-0003qV-0n for importer@patchew.org; Mon, 15 Jul 2019 22:48:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44256) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDVP-000264-Mu for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:47:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnDVO-0004TR-Km for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:47:51 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:33398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnDVM-0004Qj-Ek; Mon, 15 Jul 2019 22:47:48 -0400 Received: by mail-pl1-x644.google.com with SMTP id c14so9278874plo.0; Mon, 15 Jul 2019 19:47:48 -0700 (PDT) Received: from bobo.local0.net ([203.220.8.141]) by smtp.gmail.com with ESMTPSA id x8sm16557837pfa.46.2019.07.15.19.47.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 19:47:47 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=aspJFmRkiuGl98ZZpfTk4UAxRVGqt3PVQT6yVoIbn6Q=; b=BKX56AuBGgyx61xd76VALGoghvtPYsdpPunNIhrOhrZO6PT7+F0A/FcT4zr8Ji/Dn+ uMcGUj1L11CVPEgTxBnraY/X8N8BhXzh0m9zzA/2RqmdJhxzHb3JfYkScFB7rZHnLaFL 4zG7oWBHEclgwysCSRIJfqA9WwPmSUp3hA0jC2V8Cnl4cwOptrInvGpy/aEXgtSjQ9Y5 dorpi5MnxTxrjJTYT067NLPkHkMwhKwGqBMXCnFyack+41KTBLkR5K81PJ+y3qG0BR7q Omp4Y3pnLzBmE4g8WSTgytbbpZCH4hVXQ0+b93cGnK+BkZC/yWi1AbZqxiNVFCs/u8d3 d3HA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=aspJFmRkiuGl98ZZpfTk4UAxRVGqt3PVQT6yVoIbn6Q=; b=tgkUo0JFpio1Dyhh6e1SDaw/qkj8Rg9Yf9X81WkzR5ayR8x6pcX1+OO0kbbhNkHgq7 5kH5t3a15dZzDmjYZQqsNr1Tm97+wiDG0Y1YbqXY6lGcp1JTNKtRBJV+qOiKqXNoB3zi 4IKvUqh362JVwZlgp4wdRe+hNUrijYCvhxq2RNKQolej9Bh3pBG7+nio9b+h/Xk7SVex IV5+/SwcQqzy3xi7h2xAviVn/SMN9Q4Q4X8RpFHJ/bjgNdw9BimJrtpa+WLRRklj+hM/ zs/d0BJCElFETkz3wI2IY+DoR1zzwL3ka+iN780p2nCl8EWLXmdxjQUjvICINFgpkbhE xAlA== X-Gm-Message-State: APjAAAWfHUBpkS2kqmWeCeyuqq/RE49kL8wnXaJSbOt/gOfJ2Yx2V8NK 8wNiFIz2zNZQ2ulhkPHE2WQ= X-Google-Smtp-Source: APXvYqz7u4Sfb++ZR0r6HA7JvgJecqVTPvQO0vDgY6Esj/PAY1mWowkMO5+ojotTEOYGJHm/bAflSA== X-Received: by 2002:a17:902:f082:: with SMTP id go2mr33697942plb.25.1563245267578; Mon, 15 Jul 2019 19:47:47 -0700 (PDT) From: Nicholas Piggin To: David Gibson Date: Tue, 16 Jul 2019 12:47:23 +1000 Message-Id: <20190716024726.17864-3-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190716024726.17864-1-npiggin@gmail.com> References: <20190716024726.17864-1-npiggin@gmail.com> 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::644 Subject: [Qemu-devel] [PATCH v4 2/5] spapr: Implement H_PROD 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: Greg Kurz , Nicholas Piggin , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, =?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" H_PROD is added, and H_CEDE is modified to test the prod bit according to PAPR. Signed-off-by: Nicholas Piggin --- hw/ppc/spapr_hcall.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index e615881ac4..8b208ab259 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1050,14 +1050,41 @@ static target_ulong h_cede(PowerPCCPU *cpu, SpaprMa= chineState *spapr, { CPUPPCState *env =3D &cpu->env; CPUState *cs =3D CPU(cpu); + SpaprCpuState *spapr_cpu =3D spapr_cpu_state(cpu); =20 env->msr |=3D (1ULL << MSR_EE); hreg_compute_hflags(env); + + if (spapr_cpu->prod) { + spapr_cpu->prod =3D false; + return H_SUCCESS; + } + if (!cpu_has_work(cs)) { cs->halted =3D 1; cs->exception_index =3D EXCP_HLT; cs->exit_request =3D 1; } + + 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; + SpaprCpuState *spapr_cpu =3D spapr_cpu_state(cpu); + + cs =3D CPU(spapr_find_cpu(target)); + if (!cs) { + return H_PARAMETER; + } + + spapr_cpu->prod =3D true; + cs->halted =3D 0; + qemu_cpu_kick(cs); + return H_SUCCESS; } =20 @@ -1882,6 +1909,8 @@ 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_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 From nobody Tue Apr 30 05:02:04 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=1563245342; cv=none; d=zoho.com; s=zohoarc; b=UwT4N/iUaTsSUPpcchPfM3Zb4anGjx2Buou1s6adBitnM95VzFlawng+zVX+qhiMsXYLV1rC8jN/nbFi5MSTCbyZyj3ivBZjp5pTJ78OcjESJlHcsu2SZVIVwgFTaZtL7lwHaBYAoJGqszIyYFjtU0jxTryBiyA3QCScNoc8uEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563245342; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MdtW8CuvYdkhDUoUgf1LxOsNkRLOuv7x20g9x/4mLVg=; b=dwdTlOAiPXlZOlXsBD2bXtBOzxBecfZo6jBTJN7nyPmTeoEPv9krYfG/M/i448shTlpJcHzEY/28lnT91q+iGZyWGWpG21Pn2Jd7MEVifm5yfAD/MhuXB/Wc55Daz5mPbPlGqsSj11w/1qfPslEFoIRO3nh77kee4U+ZbeQqay4= 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 156324534254437.28617315096551; Mon, 15 Jul 2019 19:49:02 -0700 (PDT) Received: from localhost ([::1]:44986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDWX-0006pe-CC for importer@patchew.org; Mon, 15 Jul 2019 22:49:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44321) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDVU-0002TK-Hh for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:47:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnDVT-0004Wi-B3 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:47:56 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnDVR-0004UY-3W; Mon, 15 Jul 2019 22:47:53 -0400 Received: by mail-pl1-x642.google.com with SMTP id t14so9271263plr.11; Mon, 15 Jul 2019 19:47:52 -0700 (PDT) Received: from bobo.local0.net ([203.220.8.141]) by smtp.gmail.com with ESMTPSA id x8sm16557837pfa.46.2019.07.15.19.47.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 19:47:51 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=MdtW8CuvYdkhDUoUgf1LxOsNkRLOuv7x20g9x/4mLVg=; b=Kkg+t5l/JSXrrd4G1WmWSklPmahpG1n7pTy+67V3HxNO4JdsLoO3JTicKcReljIakV Lqn8sXxaMV/eZieMNc8bTaUKNwEvfeKEOhPprKpAsl+YmikKWLA6mb9V89kCRfihl7oq KhVnQqhNnGiSSA0wZYJsFZt/fh4Cf+GJD8vye8ewU9gjlUl8ZZ/+QTzqPGQZO8v7cX/V fJ8MXZQWPthRg9jq3R8OIwazaR7ttYearCcjeVbxr5KoRFey2SadWPP9O4P+eyCh9yxy pFr8c8PyT4EIDb0eqd5jQlH8O6q4l3kYjfxmgD8wtdML8pGvFxeXLio+PHv2l3soAlod xIog== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=MdtW8CuvYdkhDUoUgf1LxOsNkRLOuv7x20g9x/4mLVg=; b=YXcf6ndYMiciuc679tmqe11VuuZJPzx51A8NP9e1NyVLVRN10iQCQ6s16RJXSl0/JW VZ3jXU0J0spgWC5zLSEfMNLEvRayWMOBae0ygtL7xwf/tspTgT9UfdRBRvLcme83D0Op CO5jX32zG4PHwL7n9RoTeW2MTbrRaD/OLIhW8DkueBxEAZ1nHPWtyuK7/zyCoA4AmoT8 pY+fD4L7kBCWS76ygopEU6NqlaT7ivnhXqGp0e/1XuEZ+tWSWEXuNqwnNarboNiMDGH3 i8EFi2vTFIISny2I5MBIrBk4hrRSNXAKS7bWSUveTEtP4h3698fePlvG2L0VjK3+ec6K PQEw== X-Gm-Message-State: APjAAAVc4axexW5vhgVZY853xnJcfA+zcjp+5ZuhpkfxbRGWQK92Cj/S kvNGJLQcZu2ve4SHoiysNq8= X-Google-Smtp-Source: APXvYqyDkuMUoZflY9Z/M2w/Bx0ALzYnQwOJ0Uv8KYdzrJXchaqWjKZnQEb2FnXtMvBcLv/s9FeslQ== X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr32390317pll.321.1563245271705; Mon, 15 Jul 2019 19:47:51 -0700 (PDT) From: Nicholas Piggin To: David Gibson Date: Tue, 16 Jul 2019 12:47:24 +1000 Message-Id: <20190716024726.17864-4-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190716024726.17864-1-npiggin@gmail.com> References: <20190716024726.17864-1-npiggin@gmail.com> 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 v4 3/5] spapr: Implement H_CONFER 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: Greg Kurz , Nicholas Piggin , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, =?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" This does not do directed yielding and is not quite as strict as PAPR specifies in terms of precise dispatch behaviour. This generally will mean suboptimal performance, rather than guest misbehaviour. Linux does not rely on exact dispatch behaviour. Signed-off-by: Nicholas Piggin --- hw/ppc/spapr_hcall.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 8b208ab259..28d58113be 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1069,6 +1069,53 @@ 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]; + uint32_t dispatch =3D args[1]; + PowerPCCPU *target_cpu =3D spapr_find_cpu(target); + CPUState *target_cs =3D CPU(target_cpu); + CPUState *cs =3D CPU(cpu); + SpaprCpuState *spapr_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 && !target_cs) { + return H_PARAMETER; + } + + spapr_cpu =3D spapr_cpu_state(target_cpu); + + /* + * PAPR specifies waiting until proded in this case, without dispatch + * counter check. + */ + if (cpu =3D=3D target_cpu) { + if (spapr_cpu->prod) { + spapr_cpu->prod =3D false; + return H_SUCCESS; + } + + cs->halted =3D 1; + cs->exception_index =3D EXCP_HALTED; + cs->exit_request =3D 1; + + return H_SUCCESS; + } + + if (spapr_cpu->dispatch_counter !=3D dispatch || (dispatch & 1) =3D=3D= 0) { + return H_SUCCESS; + } + + 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) { @@ -1909,6 +1956,7 @@ 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); =20 spapr_register_hypercall(H_SIGNAL_SYS_RESET, h_signal_sys_reset); --=20 2.20.1 From nobody Tue Apr 30 05:02:04 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=1563245339; cv=none; d=zoho.com; s=zohoarc; b=HkK0ga4vDLISLbyEWyY77K9miiDGR/gVIO+3TdPoS7TVcR2t7FiA8rZ73VbGF19nz7il5zHziugG6Wy3V68OE6bSetpR/gqGqwGlJEntFQ9RBDgXnVY+LGZhee8cQBFMT8IWnYNKS/em5hnL2yKuuc97vqGnh75ED6UVqbq4tiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563245339; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=De2i1fnAfzCHclgXYbgQlJSwI5p8Wu3AzTld5je3ygM=; b=FmYK0jWCW7fxG+zAr5/eKwgg76BGU7WuIHol9GDM86BqiccZ0K5w/YpsNJcFkUcco5ENLJVnKRsWJfkFeZu3mf70gmu7aIdArS2sQTx3GONLnqK30akgNlENdE06gwZUFs+cgmjWCTnl/ZhJmM6rMCAwr+qJcbh/1w95CVbXmFQ= 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 1563245339579230.8281581183836; Mon, 15 Jul 2019 19:48:59 -0700 (PDT) Received: from localhost ([::1]:44984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDWU-0006ax-8g for importer@patchew.org; Mon, 15 Jul 2019 22:48:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44362) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDVZ-0002lZ-Nu for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:48:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnDVX-0004b0-2k for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:48:00 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:38206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnDVU-0004XG-ML; Mon, 15 Jul 2019 22:47:56 -0400 Received: by mail-pl1-x641.google.com with SMTP id az7so9289493plb.5; Mon, 15 Jul 2019 19:47:56 -0700 (PDT) Received: from bobo.local0.net ([203.220.8.141]) by smtp.gmail.com with ESMTPSA id x8sm16557837pfa.46.2019.07.15.19.47.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 19:47:55 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=De2i1fnAfzCHclgXYbgQlJSwI5p8Wu3AzTld5je3ygM=; b=rJ0BBJcTKHXpHUeCqj8mOMroI0K/XgKGBrYK/VukClXRzN2Zamzl77g9HZbULHIdmO TX4vd6vDP9V/wy1b6gEh/GuPAMiFKStuIm0H222UoRzwFku0VpUiuvfhdzXaVSjjNOqH T7axs8iL6bWd7K7b5ekClPHD/ywazp38f9qK5+a+SgBkxE3zmrr/RAG+XLjJsPBgihKm ekhEUxyflwqTWkbl9dCr7w/nJGtcK1Eaj0tkoHjnDF1GswG5T+S5bj6eWzVv1u5MxOVB I+Ho/ImbMSBvsglJDSuUyt2AUHl7KIq6xTb4c+ylrggLSA+sx+nroWaNYPXkWCHbYzS9 JfDg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=De2i1fnAfzCHclgXYbgQlJSwI5p8Wu3AzTld5je3ygM=; b=cxmifrsaoc+BZDMiOLsmsE+E+uq5eH2RsX/4BmavdDBdLi+ZcP8W3LY+1trWHGKkN3 AZUyOjNcTB3hRMutjduGmjldh2oNhtT8Gxpilh+ORCcqHZ8ZLEhg9hkMiVX1jvUWCTKf DMdYbVdc2PZ1JlW8a1LiG6dUTcF/jOG2MJNJm3NtPDgBKg3z0xS4IDeRpbzMcQvGEu6A sKBvjeJmmFMyJQ1Y8sueOnbXl/9CHecUnwqqHxLEQXvYhh7VKTv4zbS0WnxZpcJ4byNg 0ucniVRCKGWgp3nHW3Yr3VkGUWeYSjIPTOMbYZx5lbnf5vZC7ewfTzN9PP4JNj0IO9+X KWmQ== X-Gm-Message-State: APjAAAVyhcZ4RPgdx1AIlb24JtS+GC6CSmZsuSUMgnHhTrUHF2Cu/mEX mfJuQ6vp3AOhEl/rtpBkXNM= X-Google-Smtp-Source: APXvYqwRlDATVV1lxvR8Qb0O4+geDHpG6AeK5ZXZKjk9Z+4SsbItqXhenuzApA4kEWAL1EZHn4C0WQ== X-Received: by 2002:a17:902:9a85:: with SMTP id w5mr32208781plp.221.1563245275880; Mon, 15 Jul 2019 19:47:55 -0700 (PDT) From: Nicholas Piggin To: David Gibson Date: Tue, 16 Jul 2019 12:47:25 +1000 Message-Id: <20190716024726.17864-5-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190716024726.17864-1-npiggin@gmail.com> References: <20190716024726.17864-1-npiggin@gmail.com> 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::641 Subject: [Qemu-devel] [PATCH v4 4/5] spapr: Implement H_JOIN 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: Greg Kurz , Nicholas Piggin , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, =?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" This has been useful to modify and test the Linux pseries suspend code but it requires modification to the guest to call it (due to being gated by other unimplemented features). It is not otherwise used by Linux yet, but work is slowly progressing there. Signed-off-by: Nicholas Piggin --- hw/ppc/spapr.c | 1 + hw/ppc/spapr_hcall.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 87b11e2484..5c54e1cb9a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1066,6 +1066,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, v= oid *fdt) add_str(hypertas, "hcall-tce"); add_str(hypertas, "hcall-vio"); add_str(hypertas, "hcall-splpar"); + add_str(hypertas, "hcall-join"); add_str(hypertas, "hcall-bulk"); add_str(hypertas, "hcall-set-mode"); add_str(hypertas, "hcall-sprg0"); diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 28d58113be..52847a7047 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1069,6 +1069,47 @@ 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; + SpaprCpuState *spapr_cpu =3D spapr_cpu_state(cpu); + bool last_unjoined =3D true; + + if (env->msr & (1ULL << MSR_EE)) { + return H_BAD_MODE; + } + + if (spapr_cpu->prod) { + spapr_cpu->prod =3D false; + return H_SUCCESS; + } + + CPU_FOREACH(cs) { + PowerPCCPU *c =3D POWERPC_CPU(cs); + CPUPPCState *e =3D &c->env; + if (c =3D=3D cpu) + continue; + + /* Don't have a way to indicate joined, so use halted && MSR[EE]=3D0 */ + if (!cs->halted || (e->msr & (1ULL << MSR_EE))) { + last_unjoined =3D false; + break; + } + } + if (last_unjoined) { + return H_CONTINUE; + } + + cs =3D CPU(cpu); + 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) { @@ -1959,6 +2000,9 @@ static void hypercall_register_types(void) spapr_register_hypercall(H_CONFER, h_confer); spapr_register_hypercall(H_PROD, h_prod); =20 + /* hcall-join */ + spapr_register_hypercall(H_JOIN, h_join); + spapr_register_hypercall(H_SIGNAL_SYS_RESET, h_signal_sys_reset); =20 /* processor register resource access h-calls */ --=20 2.20.1 From nobody Tue Apr 30 05:02:04 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=1563245322; cv=none; d=zoho.com; s=zohoarc; b=fHQCwkxEbk7e2BwR+CkdtRnCvLOx2XBQH9ZJ+Y88Yawe7B22R5MUDpCLMUcs8uyGKsbuiprvkZVZpLwnBtcd6fbWOIvig1CIN6Dq65LcRVixFgFUOkcVYL1Ee/Z4F6NLobzAA7epCRUROdNUEInRDRhQdoaqo2/nEiVhBQOn/CA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563245322; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=e2dPud5PCxHxMG9QDmjQcp4vS6NKyFk8d+yIr1hiXRY=; b=DttS4X3dEjc7to9XPZRyNiO1bbcPAxe5zcDA0jfm+ps3b6QcqRIIodohgzaeLJkQukItLsgTnyTz3nzewFif4pAydTMcvpSuKjgY+coIYPxEOeBuRLREjVyXzBNNBrZDcURT+BW0iXFp7Kffc/tx9joyHXUh53Z5yS8EcWoPzMQ= 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 1563245322389629.0850061959386; Mon, 15 Jul 2019 19:48:42 -0700 (PDT) Received: from localhost ([::1]:44968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDWC-0005BN-Mh for importer@patchew.org; Mon, 15 Jul 2019 22:48:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44428) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnDVd-00035F-BL for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:48:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnDVb-0004df-Vm for qemu-devel@nongnu.org; Mon, 15 Jul 2019 22:48:05 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:38770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnDVY-0004be-S1; Mon, 15 Jul 2019 22:48:01 -0400 Received: by mail-pf1-x442.google.com with SMTP id y15so8347672pfn.5; Mon, 15 Jul 2019 19:48:00 -0700 (PDT) Received: from bobo.local0.net ([203.220.8.141]) by smtp.gmail.com with ESMTPSA id x8sm16557837pfa.46.2019.07.15.19.47.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 19:47:59 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=e2dPud5PCxHxMG9QDmjQcp4vS6NKyFk8d+yIr1hiXRY=; b=majXZKOd789jiH8CvODQrazuiZotMNH4anIlPhsXdMnJSMFKeYBndaHINWFjhvveC5 wGldN1idZc0fzjCTflgOajT9lyINsx0/UiGteY/kyqr9Y6X+0r5qdx0rgEPivz03phM9 dVSwdqUhfdzvBMK3eWjurVStvrAuSUgLSsSaHOL7pmMHLLQ95Ot5+9GnSybFdIPsh6b9 121dWZwnW9xQKSj7Xt6EyY9P0Vxrp7f7pDYd3BASXE8UJQaZ+b/mW1tF6V0YsUnapOWQ 5FiM/L5D6mCN62+Mi8HG02lQbB2uZdHxhNWsAHRJPNnQbQ0QSx+K1UPtlNNZbgn7F/BP 1E1g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=e2dPud5PCxHxMG9QDmjQcp4vS6NKyFk8d+yIr1hiXRY=; b=oDMD6Q46hZ/YtA2Vfkrg8+ylhXgba2abxRwDraDH0dbF33neCUHDWS42Y3pFtbheO9 MDw6WhI/xmdfRO6wecW8un3Ene4OtsNeC4O6WKIuO7Mb5T/47U/wVwMy1rSFhnCM8SrH ZJ5e33i0IVWhPda75+MUB6IM6mg12iyn7kF7YhTl+tSIY5x5PA66lZBus7GvEoDAy7Br q4oiYmH1Cm0V+ryck+hYlMMyX5A8kj4xaIXzmQktCgi9ti9VBxUrganhggEUNM1kJUKO OysbrBorK2vnc9D+AwW9GNMswwfNBcsfbMaLYQMxVDimbv6QH5icQkqa0iUaL89HVtps FPLA== X-Gm-Message-State: APjAAAU4fH2WE5Mn/BXctSkjQKSyNxYwIcyef2BqohaRd5k1zlgc3Tlv 3ocTtTUcBoApaDMdNy81EKE= X-Google-Smtp-Source: APXvYqxsepVTxOnFpMTLu8zaAj4mzscjX+tukDPBMiz9uecGaonsbAmyelq7glsgRf7VH9qAB+nCrA== X-Received: by 2002:a63:4e60:: with SMTP id o32mr31065659pgl.68.1563245279762; Mon, 15 Jul 2019 19:47:59 -0700 (PDT) From: Nicholas Piggin To: David Gibson Date: Tue, 16 Jul 2019 12:47:26 +1000 Message-Id: <20190716024726.17864-6-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190716024726.17864-1-npiggin@gmail.com> References: <20190716024726.17864-1-npiggin@gmail.com> 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::442 Subject: [Qemu-devel] [PATCH v4 5/5] spapr: Implement ibm,suspend-me 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: Greg Kurz , Nicholas Piggin , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, =?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" This has been useful to modify and test the Linux pseries suspend code but it requires modification to the guest to call it (due to being gated by other unimplemented features). It is not otherwise used by Linux yet, but work is slowly progressing there. This allows a (lightly modified) guest kernel to suspend with `echo mem > /sys/power/state` and be resumed with system_wakeup monitor command. Signed-off-by: Nicholas Piggin --- hw/ppc/spapr.c | 26 ++++++++++++++++++++++++++ hw/ppc/spapr_rtas.c | 32 ++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 7 ++++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5c54e1cb9a..b85d41bb1e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1710,6 +1710,11 @@ static void spapr_machine_reset(MachineState *machin= e) void *fdt; int rc; =20 + if (spapr->suspend_reset) { + spapr->suspend_reset =3D false; + return; + } + spapr_caps_apply(spapr); =20 first_ppc_cpu =3D POWERPC_CPU(first_cpu); @@ -2721,6 +2726,23 @@ static PCIHostState *spapr_create_default_phb(void) return PCI_HOST_BRIDGE(dev); } =20 +static Notifier wakeup; +static void spapr_notify_wakeup(Notifier *notifier, void *data) +{ + WakeupReason *reason =3D data; + + switch (*reason) { + case QEMU_WAKEUP_REASON_RTC: + break; + case QEMU_WAKEUP_REASON_PMTIMER: + break; + case QEMU_WAKEUP_REASON_OTHER: + break; + default: + break; + } +} + /* pSeries LPAR / sPAPR hardware init */ static void spapr_machine_init(MachineState *machine) { @@ -3078,6 +3100,10 @@ static void spapr_machine_init(MachineState *machine) =20 qemu_register_boot_set(spapr_boot_set, spapr); =20 + wakeup.notify =3D spapr_notify_wakeup; + qemu_register_wakeup_notifier(&wakeup); + qemu_register_wakeup_support(); + if (kvm_enabled()) { /* to stop and start vmclock */ qemu_add_vm_change_state_handler(cpu_ppc_clock_vm_state_change, diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index a618a2ac0f..60a007ec38 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -216,6 +216,36 @@ static void rtas_stop_self(PowerPCCPU *cpu, SpaprMachi= neState *spapr, qemu_cpu_kick(cs); } =20 +static void rtas_ibm_suspend_me(PowerPCCPU *cpu, SpaprMachineState *spapr, + uint32_t token, uint32_t nargs, + target_ulong args, + uint32_t nret, target_ulong rets) +{ + CPUState *cs; + + if (nargs !=3D 0 || nret !=3D 1) { + rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); + return; + } + + CPU_FOREACH(cs) { + PowerPCCPU *c =3D POWERPC_CPU(cs); + CPUPPCState *e =3D &c->env; + if (c =3D=3D cpu) + continue; + + /* See h_join */ + if (!cs->halted || (e->msr & (1ULL << MSR_EE))) { + rtas_st(rets, 0, H_MULTI_THREADS_ACTIVE); + return; + } + } + + spapr->suspend_reset =3D true; + qemu_system_suspend_request(); + rtas_st(rets, 0, RTAS_OUT_SUCCESS); +} + static inline int sysparm_st(target_ulong addr, target_ulong len, const void *val, uint16_t vallen) { @@ -483,6 +513,8 @@ static void core_rtas_register_types(void) rtas_query_cpu_stopped_state); spapr_rtas_register(RTAS_START_CPU, "start-cpu", rtas_start_cpu); spapr_rtas_register(RTAS_STOP_SELF, "stop-self", rtas_stop_self); + spapr_rtas_register(RTAS_IBM_SUSPEND_ME, "ibm,suspend-me", + rtas_ibm_suspend_me); spapr_rtas_register(RTAS_IBM_GET_SYSTEM_PARAMETER, "ibm,get-system-parameter", rtas_ibm_get_system_parameter); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 5d36eec9d0..df0b0c15da 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -171,6 +171,10 @@ struct SpaprMachineState { bool use_hotplug_event_source; SpaprEventSource *event_sources; =20 + /* Machine has been suspended, so the next machine_reset should not + * reset state, but just return and allow execution to resume. */ + bool suspend_reset; + /* ibm,client-architecture-support option negotiation */ bool cas_reboot; bool cas_legacy_guest_workaround; @@ -631,8 +635,9 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ul= ong opcode, #define RTAS_IBM_CREATE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x27) #define RTAS_IBM_REMOVE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x28) #define RTAS_IBM_RESET_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x29) +#define RTAS_IBM_SUSPEND_ME (RTAS_TOKEN_BASE + 0x2A) =20 -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2A) +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2B) =20 /* RTAS ibm,get-system-parameter token values */ #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20 --=20 2.20.1