From patchwork Fri Jul 5 21:06:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11033339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C02D912 for ; Fri, 5 Jul 2019 21:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC50288F8 for ; Fri, 5 Jul 2019 21:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0052528A4F; Fri, 5 Jul 2019 21:07:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5AD2288F8 for ; Fri, 5 Jul 2019 21:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbfGEVHX (ORCPT ); Fri, 5 Jul 2019 17:07:23 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38198 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727212AbfGEVHX (ORCPT ); Fri, 5 Jul 2019 17:07:23 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x65L3vH1025588; Fri, 5 Jul 2019 21:07:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=sSX5aIb6pbrZni5vNE5EzSGZsrAPvnkvicgxxh+1deg=; b=2H2Sg3VC4gyG44Hc9EYoACCOWiSas3tNxNak7pFM/GjtmLcn4NaP+lF7Gi5gUUiRpFcV BNgFRxOz3dMuDHW9u9ov6E3HeBKMakwGHIMY+aPXNZY8jZMutGv5QS60V8TfLeWC10wM OiG4jCx0h8+wu8Xgz0U4SlUF0rz74fpq+tF8jUk/T1RIa5dkBr80v2PD7Du/FPeJRiSL 9NsjjvSnY2brUcu+pO0qy7NT71quMm15aofCwtqzyK3tlgqD0QXW5AxLc3zIFhFVFlzt CGF/xzHtIs0LjhCv4nSyIYdD+B6PTJiiqcxt09Bqr9ecAW/kmZgoa1Nt9lC/k4vtg5ST bQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2te5tc4j6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2019 21:07:01 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x65L2ULs175825; Fri, 5 Jul 2019 21:07:01 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2th5qmx76h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2019 21:07:01 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x65L70ax030850; Fri, 5 Jul 2019 21:07:00 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 05 Jul 2019 14:07:00 -0700 From: Liran Alon To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, ehabkost@redhat.com, kvm@vger.kernel.org, Liran Alon , Joao Martins Subject: [PATCH 2/4] target/i386: kvm: Init nested-state for vCPU exposed with SVM Date: Sat, 6 Jul 2019 00:06:34 +0300 Message-Id: <20190705210636.3095-3-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190705210636.3095-1-liran.alon@oracle.com> References: <20190705210636.3095-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9309 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=827 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907050266 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9309 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=871 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907050266 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Joao Martins Signed-off-by: Liran Alon Reviewed-by: Maran Wilson --- target/i386/cpu.h | 5 +++++ target/i386/kvm.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 93345792f4cb..cdb0e43676a9 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1867,6 +1867,11 @@ static inline bool cpu_has_vmx(CPUX86State *env) return env->features[FEAT_1_ECX] & CPUID_EXT_VMX; } +static inline bool cpu_has_svm(CPUX86State *env) +{ + return env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM; +} + /* fpu_helper.c */ void update_fp_status(CPUX86State *env); void update_mxcsr_status(CPUX86State *env); diff --git a/target/i386/kvm.c b/target/i386/kvm.c index b57f873ec9e8..4e2c8652168f 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1721,6 +1721,8 @@ int kvm_arch_init_vcpu(CPUState *cs) env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX; vmx_hdr->vmxon_pa = -1ull; vmx_hdr->vmcs12_pa = -1ull; + } else if (cpu_has_svm(env)) { + env->nested_state->format = KVM_STATE_NESTED_FORMAT_SVM; } }