From nobody Tue May 21 03:45:58 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; 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=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1562738887; cv=none; d=zoho.com; s=zohoarc; b=cyB5U8hpTFVmR2MJqnJFqyC3XWydGU5yWSplP1voS54V7ran2PbSqsPKqMq+VFQlmzICGCzXncfsDaoNCFw0mmI14WvniWKD+rgyT3kDO9haYX9NkE80/XKFeuvW1imke4bAptpI4dD/gA9FpYCKe5hnqdlQvke2yU+tmbt3Wto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562738887; h=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=Tn9MZtYPSUZHEXv8G15/5wixegWjbwUp3/rnFO/p77U=; b=IXRZ/M7b1I0UTBJTCwn0+A7u/MzkD+LD/DCnmXiawUoaHjJmFUtSI8LiFy3GK4x7GEtVZYy6Xbx3wDFfemCRi+pFZjgVN8VHE0RoVOVRTMmBFDeWi2JAPGCpNulla7BicBNQwHKXqO3xlKvuqTeE1e+GID0Gkqch3moboobCCyA= 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; 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 1562738887834617.964987132727; Tue, 9 Jul 2019 23:08:07 -0700 (PDT) Received: from localhost ([::1]:58156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hl5lZ-0004Mb-Bb for importer@patchew.org; Wed, 10 Jul 2019 02:07:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35628) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hl5ka-0003qZ-Br for qemu-devel@nongnu.org; Wed, 10 Jul 2019 02:06:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hl5kY-0002xn-UJ for qemu-devel@nongnu.org; Wed, 10 Jul 2019 02:06:44 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:13470) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hl5kY-0002tw-Jp for qemu-devel@nongnu.org; Wed, 10 Jul 2019 02:06:42 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6A62dhd013198 for ; Wed, 10 Jul 2019 02:06:34 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tn7exnsge-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 10 Jul 2019 02:06:34 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jul 2019 07:06:31 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 10 Jul 2019 07:06:28 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6A66RmH49741970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jul 2019 06:06:28 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D135A52057; Wed, 10 Jul 2019 06:06:27 +0000 (GMT) Received: from bharata.in.ibm.com (unknown [9.124.35.218]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id D570E52052; Wed, 10 Jul 2019 06:06:26 +0000 (GMT) From: Bharata B Rao To: qemu-devel@nongnu.org Date: Wed, 10 Jul 2019 11:36:21 +0530 X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19071006-0008-0000-0000-000002FB7D51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19071006-0009-0000-0000-00002268DFF9 Message-Id: <20190710060621.16430-1-bharata@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-10_02:, , 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907100074 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v0] ppc/spapr: Support reboot of secure pseries 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: linuxram@us.ibm.com, Bharata B Rao , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A pseries guest can be run as a secure guest on Ultravisor-enabled POWER platforms. When such a secure guest is reset, we need to release/reset a few resources both on ultravisor and hypervisor side. This is achieved by invoking this new ioctl KVM_PPC_SVM_OFF from the machine reset path. As part of this ioctl, the secure guest is essentially transitioned back to normal mode so that it can reboot like a regular guest and become secure again. This ioctl has no effect when invoked for a normal guest. Signed-off-by: Bharata B Rao --- * The ioctl implementation in the kernel can be found as part of this patch= set: https://www.spinics.net/lists/linux-mm/msg184366.html * Updated linux-headers/linux/kvm.h here for completeness as the definition of KVM_PPC_SVM_OFF isn't yet part of upstream kernel. hw/ppc/spapr.c | 1 + linux-headers/linux/kvm.h | 1 + target/ppc/kvm.c | 7 +++++++ target/ppc/kvm_ppc.h | 6 ++++++ 4 files changed, 15 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 821f0d4a49..6abf71f159 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1709,6 +1709,7 @@ static void spapr_machine_reset(MachineState *machine) void *fdt; int rc; =20 + kvmppc_svm_off(); spapr_caps_apply(spapr); =20 first_ppc_cpu =3D POWERPC_CPU(first_cpu); diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index c8423e760c..9603fef9bf 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1327,6 +1327,7 @@ struct kvm_s390_ucas_mapping { #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_inf= o) /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) +#define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb2) =20 /* ioctl for vm fd */ #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 8a06d3171e..079d83ce6c 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2953,3 +2953,10 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64= _t tb_offset) kvm_set_one_reg(cs, KVM_REG_PPC_TB_OFFSET, &tb_offset); } } + +int kvmppc_svm_off(void) +{ + KVMState *s =3D KVM_STATE(current_machine->accelerator); + + return kvm_vm_ioctl(s, KVM_PPC_SVM_OFF); +} diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 98bd7d5da6..0fd80e1100 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -37,6 +37,7 @@ int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, bool radix, bool gtse, uint64_t proc_tbl); +int kvmppc_svm_off(void); #ifndef CONFIG_USER_ONLY bool kvmppc_spapr_use_multitce(void); int kvmppc_spapr_enable_inkernel_multitce(void); @@ -201,6 +202,11 @@ static inline target_ulong kvmppc_configure_v3_mmu(Pow= erPCCPU *cpu, return 0; } =20 +static inline int kvmppc_svm_off(void) +{ + return 0; +} + static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online) { --=20 2.21.0