From nobody Sun Apr 28 17:20:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524464087585847.2645688198194; Sun, 22 Apr 2018 23:14:47 -0700 (PDT) Received: from localhost ([::1]:44661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAUkK-00080x-OW for importer@patchew.org; Mon, 23 Apr 2018 02:14:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAUj6-0007Vv-KG for qemu-devel@nongnu.org; Mon, 23 Apr 2018 02:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAUj3-00067h-8c for qemu-devel@nongnu.org; Mon, 23 Apr 2018 02:13:24 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36018 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fAUj3-00067P-3c for qemu-devel@nongnu.org; Mon, 23 Apr 2018 02:13:21 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3N68tIl121714 for ; Mon, 23 Apr 2018 02:13:20 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hh39jb6g3-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 23 Apr 2018 02:13:19 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Apr 2018 07:13:15 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Apr 2018 07:13:13 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3N6DCV660555454; Mon, 23 Apr 2018 06:13:12 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ECA7252041; Mon, 23 Apr 2018 06:03:53 +0100 (BST) Received: from abhimanyu.in.ibm.com (unknown [9.109.206.39]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9E2B45203F; Mon, 23 Apr 2018 06:03:52 +0100 (BST) From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Mon, 23 Apr 2018 11:43:02 +0530 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 18042306-0040-0000-0000-00000431D410 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042306-0041-0000-0000-00002635F809 Message-Id: <20180423061302.24201-1-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-23_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804230066 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH] target/ppc/kvm: set vcpu as online/offline 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: paulus@samba.org, qemu-devel@nongnu.org, Nikunj A Dadhania Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Set the newly added register(KVM_REG_PPC_ONLINE) to indicate if the vcpu is online(1) or offline(0) KVM will use this information to set the RWMR register, which controls the = PURR and SPURR accumulation. CC: paulus@samba.org Signed-off-by: Nikunj A Dadhania --- http://patchwork.ozlabs.org/patch/901897/ --- hw/ppc/spapr.c | 1 + hw/ppc/spapr_rtas.c | 4 ++++ linux-headers/asm-powerpc/kvm.h | 1 + target/ppc/kvm.c | 9 +++++++++ target/ppc/kvm_ppc.h | 6 ++++++ 5 files changed, 21 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a81570e7c8..48bafe3765 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1549,6 +1549,7 @@ static void spapr_machine_reset(void) first_ppc_cpu->env.gpr[5] =3D 0; first_cpu->halted =3D 0; first_ppc_cpu->env.nip =3D SPAPR_ENTRY_POINT; + kvmppc_set_reg_ppc_online(first_ppc_cpu, 1); =20 spapr->cas_reboot =3D false; } diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 0ec5fa4cfe..0874a746dd 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -33,6 +33,7 @@ #include "sysemu/device_tree.h" #include "sysemu/cpus.h" #include "sysemu/kvm.h" +#include "kvm_ppc.h" =20 #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" @@ -184,6 +185,8 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachi= neState *spapr, spapr_cpu_set_endianness(cpu); spapr_cpu_update_tb_offset(cpu); =20 + kvmppc_set_reg_ppc_online(cpu, 1); + qemu_cpu_kick(cs); =20 rtas_st(rets, 0, RTAS_OUT_SUCCESS); @@ -204,6 +207,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachin= eState *spapr, PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 cs->halted =3D 1; + kvmppc_set_reg_ppc_online(cpu, 0); qemu_cpu_kick(cs); =20 /* Disable Power-saving mode Exit Cause exceptions for the CPU. diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kv= m.h index 833ed9a16a..1b32b56a03 100644 --- a/linux-headers/asm-powerpc/kvm.h +++ b/linux-headers/asm-powerpc/kvm.h @@ -633,6 +633,7 @@ struct kvm_ppc_cpu_char { #define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd) =20 #define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe) +#define KVM_REG_PPC_ONLINE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf) =20 /* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 79a436a384..32a146f838 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2877,3 +2877,12 @@ bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu) =20 return !kvmppc_is_pr(cs->kvm_state); } + +void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online) +{ + CPUState *cs =3D CPU(cpu); + + if (kvm_enabled()) { + kvm_set_one_reg(cs, KVM_REG_PPC_ONLINE, &online); + } +} diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 4d2789eef6..7a915fe422 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -72,6 +72,7 @@ int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulon= g flags, int shift); bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); =20 bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path); +void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online); =20 #else =20 @@ -187,6 +188,11 @@ static inline target_ulong kvmppc_configure_v3_mmu(Pow= erPCCPU *cpu, return 0; } =20 +static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int= online) +{ + return; +} + #ifndef CONFIG_USER_ONLY static inline off_t kvmppc_alloc_rma(void **rma) { --=20 2.14.3