Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2211166ybb; Thu, 2 Apr 2020 15:37:56 -0700 (PDT) X-Google-Smtp-Source: APiQypLacxt8VdpaaneYueLWVolCGZM20dAnWSrp+JRAjNpDvMmRTkcqzI7KuCcaeGS7ZD+EkmX/ X-Received: by 2002:aca:3b82:: with SMTP id i124mr987161oia.61.1585867076265; Thu, 02 Apr 2020 15:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585867076; cv=none; d=google.com; s=arc-20160816; b=Pj2/NklS2zf+QmYfJ/92wzIt8R+hL4Oko6+wV9xNwZtYdI85nrNO2P6kaUhOHZQIIl Pxp2DGl4FEk2MSs3LDYGQiBjESmjAFyW0FXVZtWT7Ye10vDVVtNplKZEoJe4ViCdFEa2 +hKIgkN16WlKYWEvJ1+B8Yt0Yg0RV2unoRulCTAUwpMfUE0SCMPsDuGUhxtfg216rkb5 4/Jo921Ac8c9Y4I2UR4SENr2oLWYr8Jm7b8Yst8sI6YO2qLGJlJgVffe/bfDTDV1qxAv Q+OV9mfgALXdcxemWEA290HmIvwq+EMpu8XtBKC2RHBZGAI6levlQyXGFahBDdR5kcYN Fusw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/6uoxnnJoOeGgVzkYhxiBt1cqT19bh9GMo8CCS7Cf88=; b=kqcYZuTQDORmNUfY6dSpYmLiRVzGhqLVNV6/pibn7OgkdEQJM/r2O+6L8N0K9StIRa nzK3+2CLLGMj0trdhvq0Qlg0GEkEujTTZtTrYo4FyHCYzcev3HlWOuNhDiipnDb0Epgl roJ33PasuA9qKWYYFKD4ct/nLjDW5TnbJKTy2WVrsdtuJ04RQSZMIcHLRIDk+5CyVnoF yVH//zQ5Vvhax8GA1yEB2N8egAyo4nqHHRQoyb2/+xBi/ZteFrgzY3uOs8tUtCjo7jIp 4fkRGJj0sYpwRnp8SIftNF3Z533T+pptoZJ/1dEfbiM+PIMsszQgzIs9RPz146NNCjV2 y+yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Rg65ilh6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c67si3008091oif.5.2020.04.02.15.37.43; Thu, 02 Apr 2020 15:37:56 -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; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Rg65ilh6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388595AbgDBWhZ (ORCPT + 99 others); Thu, 2 Apr 2020 18:37:25 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59854 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbgDBWhZ (ORCPT ); Thu, 2 Apr 2020 18:37:25 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 032MXwxV073343; Thu, 2 Apr 2020 22:37:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2020-01-29; bh=/6uoxnnJoOeGgVzkYhxiBt1cqT19bh9GMo8CCS7Cf88=; b=Rg65ilh6HaH+PTMWhVr2RMU7pbQK8WXAbA7A5u4K/XbzKnrfRYD9wJEU10ghh5Y5neza S840DHxwbCY0gIpxb4oLB+TyTBRT3b16gUxtJMTliZ1bYZrzqy66W+hdKXcrco1MPwI7 cZc+HiYuECVBulcSjZg/dPEdyIn6eigXSIpQw7tPGdpjQKP5dQHOY2qSq0Xj4EFz3sKA fImlRwt1Sh2NV9q5C5bq9Z/PSRq6ADM4QZYgHp3nO317JYLUMoa/hGfRB9C4CCpv5pBu eIrdZrJi5gMskcVOBW/qTlhPiI4Yt2S1ubHRUIbtI+7mGLIWQSr20xqcszRPuwWF7pXJ hw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 303yungsjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Apr 2020 22:37:01 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 032MX9GN050436; Thu, 2 Apr 2020 22:37:01 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 304sjqsam6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Apr 2020 22:37:01 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 032MawlW015810; Thu, 2 Apr 2020 22:36:59 GMT Received: from vbusired-dt (/10.154.166.66) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Apr 2020 15:36:58 -0700 Date: Thu, 2 Apr 2020 17:36:53 -0500 From: Venu Busireddy To: Ashish Kalra Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, joro@8bytes.org, bp@suse.de, thomas.lendacky@amd.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, rientjes@google.com, srutherford@google.com, luto@kernel.org, brijesh.singh@amd.com Subject: Re: [PATCH v6 07/14] KVM: x86: Add AMD SEV specific Hypercall3 Message-ID: <20200402223653.GA659595@vbusired-dt> References: <6dda7016ab64490ac3d8e74f461f9f3d0ee3fc88.1585548051.git.ashish.kalra@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6dda7016ab64490ac3d8e74f461f9f3d0ee3fc88.1585548051.git.ashish.kalra@amd.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9579 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=1 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020166 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9579 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020166 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-03-30 06:21:52 +0000, Ashish Kalra wrote: > From: Brijesh Singh > > KVM hypercall framework relies on alternative framework to patch the > VMCALL -> VMMCALL on AMD platform. If a hypercall is made before > apply_alternative() is called then it defaults to VMCALL. The approach > works fine on non SEV guest. A VMCALL would causes #UD, and hypervisor ^^^^^^ cause > will be able to decode the instruction and do the right things. But > when SEV is active, guest memory is encrypted with guest key and > hypervisor will not be able to decode the instruction bytes. > > Add SEV specific hypercall3, it unconditionally uses VMMCALL. The hypercall ^^ which > will be used by the SEV guest to notify encrypted pages to the hypervisor. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Paolo Bonzini > Cc: "Radim Krčmář" > Cc: Joerg Roedel > Cc: Borislav Petkov > Cc: Tom Lendacky > Cc: x86@kernel.org > Cc: kvm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Brijesh Singh > Signed-off-by: Ashish Kalra Reviewed-by: Venu Busireddy > --- > arch/x86/include/asm/kvm_para.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h > index 9b4df6eaa11a..6c09255633a4 100644 > --- a/arch/x86/include/asm/kvm_para.h > +++ b/arch/x86/include/asm/kvm_para.h > @@ -84,6 +84,18 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1, > return ret; > } > > +static inline long kvm_sev_hypercall3(unsigned int nr, unsigned long p1, > + unsigned long p2, unsigned long p3) > +{ > + long ret; > + > + asm volatile("vmmcall" > + : "=a"(ret) > + : "a"(nr), "b"(p1), "c"(p2), "d"(p3) > + : "memory"); > + return ret; > +} > + > #ifdef CONFIG_KVM_GUEST > bool kvm_para_available(void); > unsigned int kvm_arch_para_features(void); > -- > 2.17.1 >