Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2269449ybb; Thu, 2 Apr 2020 16:59:26 -0700 (PDT) X-Google-Smtp-Source: APiQypJL0aitipmcB/RTjbSOav+/urpmJiHjnwooOPIM/vwlv837SFDwZ/jdWudnaRR5NXqewRr9 X-Received: by 2002:a05:6830:1bef:: with SMTP id k15mr4270338otb.372.1585871966247; Thu, 02 Apr 2020 16:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585871966; cv=none; d=google.com; s=arc-20160816; b=Zb+B/3Vz+d6UMp1F/CGJ0lM/5XGLDcwaGSVPlBVBRWjGm+O6Zf3CwUg0VgmZ9xAiri gZgT98iurYWqGVdNJCBJ74a7xqk73NRVZC5eggg2miqWG1wCZ+lq/Sm5sBePIdNQZn7w 0DA+GSuhPif5JIl3PR8ezY18NI/NWA34n6a3Eq+Qo5o09ibQspyR8tSk/WntoZrbsFai RCMDyaVpVvd1g92Q6z27OeUsYmJgboNWAP1IKjUcn15nEaZyA5B9sNHEZH3bEBb51kSv hn2mc6LVI4unmKDEeR8q52m5jDM7WvL6UAacV+rDRqermwg6IX4GhfaQ0j6vsAScHHjP JBTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Lkjj8e4/gu85bLAPJaAJv8bq0O6ffAUvmzCSEpub7TI=; b=rkago0IiceowmrUK2vsZjvVyrhxnPY9/7SBIeh/7sdfarT9wO8aRF4ysIRvuEqiKVk k8GYHRpjgI1i/Y/em+jfTziObN/j58TII4nljelBPljm33yG7ewbAlTo9KDfYKgPWpBX EAe0iV+5uNRQReIcJrvcXKRT7oI0CnA6ALrnT9dWE5c9GR462fNPCQEERN5HzQCmMd1F dvH+rrMgCUQA+GKM7VJzp7a53WiRYy9lydbV5AUEtqIj4w9NEDXpXb4EbG4XXOqfuXEx Eh7M3vm11yDHroYVDn6CpdVp0I1MnW8FmlBK0IuKirinK17vopiUtyCvcJq2o0nwjwLq WksA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=uUlpho8C; 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 s4si2939853oom.84.2020.04.02.16.59.12; Thu, 02 Apr 2020 16:59:26 -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=uUlpho8C; 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 S2390309AbgDBX5K (ORCPT + 99 others); Thu, 2 Apr 2020 19:57:10 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43900 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390235AbgDBX5J (ORCPT ); Thu, 2 Apr 2020 19:57:09 -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 032NrkxL177890; Thu, 2 Apr 2020 23:56:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=Lkjj8e4/gu85bLAPJaAJv8bq0O6ffAUvmzCSEpub7TI=; b=uUlpho8Cfd/ew+XXDJslFYIcoK5eAGAq8UMvpGl7Yk7T3Gf6Q9poazK7dvDBmpMZfljg qLsZTd99vUD5pgSzsyNzzEQ3dnsY48NKksVRc6WRqjkmQdSQK1Cxp8mWKTl5hwqkpFh4 /zEZ5R5J31I9fK2AfAU7GbLerNSQReZkVVoTiKuwiPeD3fKnX91eWpKJN5urENyTlWSD +F/D3qb/Q1sfrba3L/jLKtMOMy4UP9S59FT/yXK2TyxhMBcGJ0uw0/Z69cp5nHcLuBYV pnpi1Zrd3hx4IuVfFzK0lr/BGP88ycN5z8wwpx0y7+KS3e4IRYifz90CLTdRnPCo3Lka CA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 303yungyje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Apr 2020 23:56:42 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 032NqMrW079109; Thu, 2 Apr 2020 23:54:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 302g4wcye0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Apr 2020 23:54:41 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 032NscTl008584; Thu, 2 Apr 2020 23:54:39 GMT Received: from localhost.localdomain (/10.159.142.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Apr 2020 16:54:38 -0700 Subject: Re: [PATCH v6 07/14] KVM: x86: Add AMD SEV specific Hypercall3 To: Ashish Kalra , pbonzini@redhat.com Cc: 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 References: <6dda7016ab64490ac3d8e74f461f9f3d0ee3fc88.1585548051.git.ashish.kalra@amd.com> From: Krish Sadhukhan Message-ID: <9d1f29da-2d63-dfed-228f-b82b3cc2b777@oracle.com> Date: Thu, 2 Apr 2020 16:54:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <6dda7016ab64490ac3d8e74f461f9f3d0ee3fc88.1585548051.git.ashish.kalra@amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9579 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020176 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=0 mlxscore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020176 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/29/20 11:21 PM, 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() s/apply_alternative/apply_alternatives/ > is called then it defaults to VMCALL. The approach > works fine on non SEV guest. A VMCALL would causes #UD, and hypervisor > 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 > 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 > --- > 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); Reviewed-by: Krish Sadhukhan