Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3757464ybb; Mon, 23 Mar 2020 07:10:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs/HpUGuNmvfCPQu3ZoiUZmJCAZ/fCv22bipQjCoa/dUichGzr2wVJyVLzSPI+QgTiWEdkn X-Received: by 2002:a05:6830:451:: with SMTP id d17mr17518432otc.184.1584972659614; Mon, 23 Mar 2020 07:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584972659; cv=none; d=google.com; s=arc-20160816; b=IHXHvvc5lL0fuaaAkYtoN4fkk4svjZf8Zc0ECmGoszPz2zX/jx2DF6vwfxgvb5oC5Z wSVNI7LXD1ccnLvGQ/01hay/QfR8R7KScNvLnVSByHkm6a6P1BQtCFThp+TKdIKbnUOZ A05e8EeOM302NEzhiJ68WhMLfL098t8mP6mwXCfUKOhSo6/8tC83tnRrU2pfwJJWOF4Y /EEKUWxy9uHubWegOs8c+KzwOzgqfcHTc8lUmtCWtHwlvuR5GM86u1jE0ZsLnM5tLDf3 dR/igJjHHaPISEFK7/t/eJ3pWHwp86lhRh0ky6ZKRaRRoGAl85HtnVHitMPd7N8PCFtv tAQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=LzvwTcILnBhLDfLUpXhZ0OvyAVG4jPZulimJ6g7VevU=; b=Azk0esxE/w9cgNcXeIKAN97O7Dmm8rJe6udJikVLPDPILiNNT86Pg+1AeeEtB2b8y6 z2hxx+91PQq7fVlasQ03c1D9/LKYPOA8bf2S8KJLZtm2QWK253aUIo47b/Thpt+EMPSW hx264ZqyIQVAjVimVrGc2KKmEh4G/TABV3BciC0XhxbzscvtpsUrzrFkDjdpS8hQsmwt APwaC2FYxWpe4mSrLp9gCX9J2WxloikB07N2lFlyCIWI9UVbu1WuFKxLpNByVdw9svoL jJ4UuwpU1g1r5HUddz2uHN0ORAVtBuGyr1uQQ1RWMW8pk4cWl+Ttocbk6lQKloORQp/L A4ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e20si7584663otk.273.2020.03.23.07.10.28; Mon, 23 Mar 2020 07:10:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728550AbgCWOJz (ORCPT + 99 others); Mon, 23 Mar 2020 10:09:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54904 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728378AbgCWOJz (ORCPT ); Mon, 23 Mar 2020 10:09:55 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02NE7ClM195877; Mon, 23 Mar 2020 10:09:41 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywdr51t8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2020 10:09:40 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02NE93fE026135; Mon, 23 Mar 2020 14:09:39 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma03wdc.us.ibm.com with ESMTP id 2ywaw9gw76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2020 14:09:39 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02NE9cXc57934080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Mar 2020 14:09:38 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1CA20C6055; Mon, 23 Mar 2020 14:09:38 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BCC4CC6057; Mon, 23 Mar 2020 14:09:36 +0000 (GMT) Received: from localhost (unknown [9.85.135.158]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTPS; Mon, 23 Mar 2020 14:09:36 +0000 (GMT) From: Fabiano Rosas To: Laurent Dufour , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: Bharata B Rao , Paul Mackerras , Benjamin Herrenschmidt , Michael Ellerman Subject: Re: [PATCH 2/2] KVM: PPC: Book3S HV: H_SVM_INIT_START must call UV_RETURN In-Reply-To: <20200320102643.15516-3-ldufour@linux.ibm.com> References: <20200320102643.15516-1-ldufour@linux.ibm.com> <20200320102643.15516-3-ldufour@linux.ibm.com> Date: Mon, 23 Mar 2020 11:09:33 -0300 Message-ID: <87wo7bgo2q.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-23_05:2020-03-21,2020-03-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 clxscore=1011 suspectscore=5 mlxlogscore=999 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003230078 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Laurent Dufour writes: > When the call to UV_REGISTER_MEM_SLOT is failing, for instance because > there is not enough free secured memory, the Hypervisor (HV) has to call > UV_RETURN to report the error to the Ultravisor (UV). Then the UV will call > H_SVM_INIT_ABORT to abort the securing phase and go back to the calling VM. > > If the kvm->arch.secure_guest is not set, in the return path rfid is called > but there is no valid context to get back to the SVM since the Hcall has > been routed by the Ultravisor. > > Move the setting of kvm->arch.secure_guest earlier in > kvmppc_h_svm_init_start() so in the return path, UV_RETURN will be called > instead of rfid. > > Cc: Bharata B Rao > Cc: Paul Mackerras > Cc: Benjamin Herrenschmidt > Cc: Michael Ellerman > Signed-off-by: Laurent Dufour > --- I tested this along with the code that rejects the secure transition when it is not enabled in KVM. I have also forced a KVM_PPC_SVM_OFF (via system_reset) right after setting kvm->arch.secure_guest and nothing bad happened. Tested-by: Fabiano Rosas > arch/powerpc/kvm/book3s_hv_uvmem.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c > index 79b1202b1c62..68dff151315c 100644 > --- a/arch/powerpc/kvm/book3s_hv_uvmem.c > +++ b/arch/powerpc/kvm/book3s_hv_uvmem.c > @@ -209,6 +209,8 @@ unsigned long kvmppc_h_svm_init_start(struct kvm *kvm) > int ret = H_SUCCESS; > int srcu_idx; > > + kvm->arch.secure_guest = KVMPPC_SECURE_INIT_START; > + > if (!kvmppc_uvmem_bitmap) > return H_UNSUPPORTED; > > @@ -233,7 +235,6 @@ unsigned long kvmppc_h_svm_init_start(struct kvm *kvm) > goto out; > } > } > - kvm->arch.secure_guest |= KVMPPC_SECURE_INIT_START; > out: > srcu_read_unlock(&kvm->srcu, srcu_idx); > return ret;