From patchwork Mon Apr 12 21:56:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12198963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 666A7C433B4 for ; Mon, 12 Apr 2021 22:45:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 444446121E for ; Mon, 12 Apr 2021 22:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343826AbhDLWpZ (ORCPT ); Mon, 12 Apr 2021 18:45:25 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:51046 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241908AbhDLWpX (ORCPT ); Mon, 12 Apr 2021 18:45:23 -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 13CMdkDw170807; Mon, 12 Apr 2021 22:45:02 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=Qt1atT6nGnA+nSM5q2cYpnvhJ0KIkqhsM4wVk4kPLxc=; b=ztF5i0F1PpPj8ICWLCE6y+k/IhYCBt6/WJk2jjgNfsyDaOMY+GHsFbDzSxjwu7g4643h YTPe/yacgWQXsdlYetMvKNWY/oh1sKiv7ylCxhKuthKjUmZKADoFwEhYAs6E+mJnQSwH /HM3CBsazmAmW0EgHr9O2wjEwuvxa4llKH9LSnyWjjL5h2XwG+rHpK80HsNQa3Fa+Wsv t8G0gjy8DqX2/K7i+JlyDh7Er+Sb4QFzbkxtqW/xKV1WLjx4S5clHKoD2Hx4bnXuc6Kq ipSk2krCLIIaw0/XBKFc5i2jufdIis8uaDxd4PbTI5hugWZQlManK1E3YwCIFKMdvLqj kQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 37u3ymd9gs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:02 +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 13CMdc4E167396; Mon, 12 Apr 2021 22:45:02 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2057.outbound.protection.outlook.com [104.47.45.57]) by aserp3020.oracle.com with ESMTP id 37unwxy5sq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BiYFTJyaEDNgPdT0zZSAf6cmWKMkTEZs28K06pgeyZ1NghDEElfkhZJHszbezbF0LER0LTiN5AznhIl8uVziU+iRIJoTyRUVyVVRIiKjyY2w3ziG4SyNrRySyElLWIdJz/lr8xC3LUxccCUrb596vhig9hjmyid/Xt2pwvLqJPvk4aZ7lPkid/V+1Tdg0ciFlwzB9cMEseFu5p/tsd6Rvu+qfrTO9KJD8Xp64EPxlWKiI30dO/bF7mFumpGFzNXN7VYkAib80U7p5TL7x2CsNC2eOeCHFRQJyajDX3fUhbtQ0ilPcdI848rYlqcQbg+JBbJJo5W91+H+ji4h55/DEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qt1atT6nGnA+nSM5q2cYpnvhJ0KIkqhsM4wVk4kPLxc=; b=I0HMAbiSlMgbQ+jg9tf7+pMks7qoxVkA6RIQEffco6bVUDRY0+dI+xkRmcY9CyGBTeetGAVng0NLX2/kJ3a6rZJrHTp/dhHC8LTSL199WdDFeES7WzwqhXXj0vwbqAmhNhuTfk9JxlX0ahVO4V0uDEKHCwIEDoukrDrFlrIe8MraYEA8LS/YIMz1rplilNgr0TTr7CozQ0N9j4eU9OnMn1jAxcMBYRx8bP0+km1E53CmmXurWai/ESxuRwbZJn60MpgA02WdjNITcNzWb01rRo/0bJaCp8uA7+7OMjlrO/cbGT7KLPB4PsUUMYdH6u0fv45GL/ZgXHp5QoIAhuuNmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qt1atT6nGnA+nSM5q2cYpnvhJ0KIkqhsM4wVk4kPLxc=; b=ykdGwppETaM+Cd7fngZi8W2MnaSswSQNgFR0kZcfwqjZA2R5Rcqib2R20rXKl0kxnoeMyhqqke3Nd/6j/RKeAfvPb1bb74t6lD+HDy1jTLBDZNx+3cUSxt+e3w4a/SxrIgPX7w86amaLaupTpC03gVbTeMhnRHQtaABhchOSdgM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) by SN6PR10MB3088.namprd10.prod.outlook.com (2603:10b6:805:d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 22:44:59 +0000 Received: from SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44]) by SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44%5]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 22:44:59 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 1/7 v7] KVM: SVM: Define actual size of IOPM and MSRPM tables Date: Mon, 12 Apr 2021 17:56:05 -0400 Message-Id: <20210412215611.110095-2-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210412215611.110095-1-krish.sadhukhan@oracle.com> References: <20210412215611.110095-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) To SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.201.29) by BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 22:44:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dae410ed-f50a-40ec-ee86-08d8fe049a5e X-MS-TrafficTypeDiagnostic: SN6PR10MB3088: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fkyMPBlH1k+l0j+ITmm8JeEowPlITBNjxKpM+wb42o9ZYQxvt1G3euhHFFMPVHiItsEdvS9muCMjZ6frCAbHp721Fh98ITL3g4vWmJpmu8POfsEMLhiI8i8z3hNzQbgRP2CKUD4XxShk4BG8N2CCkbtFyfKyY00FXDDa7e7UY+msWzMNbqmr2FeatRe1O/QXaYKAjVPvlEivhwNlpZ3GRoUMQYGWQvb+vPTTvfpLHBBbVkc1cvLC/XdTfxILzFekNsHo5y6Gm8cCBPySC2bORWGV4joLgBT0k40XtXCYV6V23HfKThJoXTFgj2nsTeEujQ8jQWo8vGFHCkypPeW2zZ9iSB+DDw9QtC6NbN8nYwfK9g8uW+Mwro7dLxbLjiPs6ughsDJEDsohJMLDp/VzKt+ZUqk9iwIYNTXnhy9fGAdsTtaQxPUMq2oVFxZgHEsRPfPOTZ3EhFLGSRECzUCI1EDIFbiKXeQoV1qXXrNqyddwq8vZnmxj63OCKI065QlkGLVErPsqreTaNYwYlO589vQNCB1po3DLTVeeALOS8BKw4qoJHv/Fl0maSZ/Ovy1gNjTPyUpSKpKHGIFTaEWBzGjQxYUTV+9WOuCl2xJXDM2KK+A6nMmSX3omOMdWOOTN5S1UwMK6X2AWufWg2TxhJcj79ugf0Srk5ChpY4wUbQ0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3021.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39860400002)(396003)(83380400001)(86362001)(2906002)(956004)(316002)(1076003)(6666004)(2616005)(478600001)(4326008)(8676002)(7696005)(36756003)(6486002)(52116002)(26005)(5660300002)(186003)(16526019)(44832011)(66946007)(66556008)(38100700002)(6916009)(38350700002)(8936002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DIwURMVuPL/x+jon2lM3qDz4ZeK9Q4xJknOfNPiY4SBGc+jQIMgNu4PsvRGsnslAJKgRFsUwT0Oydc0e9cPTv5erPUnLKaNxfEeYCYPBj3bwyHtkVbzJpVJdxSB3lZLAMCqwNcf6BBSQMg7EuJyMOdsV3uYhMtTgPcWJZtjch1n8ce8n/LdHrjPyMrJzZL0tqyE3lyrGS/iJyJFGgHEPQRrfvAYF53WZzAyxMloP5CCCQ4hzOntbk7/g2RJypcKz2J6xKZVfwmONRGt9VjfH8OzMaXZaEtir1OFNMBrtp88hT1pePzcv2jyakwHmvqhYhniaHkS5iOmaT2gKBFFuqq4eJp8mQNSnEN5bfQQzHidNcqAnKk4Rapzen8im+U49iWW6jteN/ZtSN85c+EZutfCZ4z4bO9Uwl65tcRPSz9x8RuElSOo8t+9I/3OUwxNj8iIMoCX5aVSZ/g4d2To+v6z2DweXbLQrcxNVUH8yD2VUh3a4A+IvTbvN/idKfKF1VyFTSzUGP9GO8thDVDwWt0y8iytYsp/N5O4TZtnf/XX77lPkGv//1z/fdig3jRtrVgCmhu0+bFTUQPLIOkRSQTIdUHxFle4snjbq2duiHrMgnRxIaQ22dS7gCon6HdJ+RaJAxnJCZ7ryUAahtX5MxPj4xLgdUobCckMHH547ZmEw6qI1hQYlU4WfK/dcq9zN3e5qarbZSOaNtCb/B36ZWdUcHG8j9pZFUUtdNOkX/xMrrT1itk6P/ewmPctGDbMy2lWG1e3R5AW+ZAPcH9tZUzRyedzNU/WQGAiuu61ZANkmZL0sqUWiqA+v9yEKvswnBklSv0gBvCiqhgtPhV4thDt+sbwcfxaHIqzVttmhpEpWM3XnH3hBEtsyOI6i4SPRYJ/VeVN1ko5RCGaknHoOcLEc+PJ7oRDVOX7Gnm9DNtFS+3Up2ByJvWv6g/7Qgx2CFHYTBIfz+vQQmwK3x9JOV1m8OKjW5x6/ybt6zio5J/8jnnqkUWJ95/5MmU+NJ8k1d4PKoCt4waKWgACC2iOPTnXrUAL9nRoweugC2FLZsO0hRn2IJs3c/CC002bq9sfYmAfhDOOzf8l98ydKc9wKSCkHxUEpTq8mGrlzdwksl4OrRmaeHd1uufHe31vYqzfOQACHqJur/AITBi0Css/uBgnFt7OGJdrzJ16Vz5ZnOQaU1XUhSDTjPnmOMIUBPRfXvxJ2R9Co3hNTVDk8V7SKAg42M/tt5ivMgc7rOwMpjjDsX4l+TaYAn8aHQlaGsHpqTR3uosF2qc45D9Pcb7VLkUNoCsBqeSOqQct/olETMyOxaeSq1fIDbM//23TI0Cgh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dae410ed-f50a-40ec-ee86-08d8fe049a5e X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 22:44:59.8041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eTYcRd46ahDbe4Lq0BWHfvq/fHdwFyGHrW558DpDVD4FKj6duxJHX91nB/IpkisVSTc7+fP+3udJl7rLTAp7ld9nRS8SxBvVH8RBb8d563o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3088 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 X-Proofpoint-GUID: q9E_KlsPAMBV-ZODUvwACm_6wFYLe7EJ X-Proofpoint-ORIG-GUID: q9E_KlsPAMBV-ZODUvwACm_6wFYLe7EJ X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Define the actual size of the IOPM and MSRPM tables so that the actual size can be used when initializing them and when checking the consistency of their physical address. These #defines are placed in svm.h so that they can be shared. Suggested-by: Sean Christopherson Signed-off-by: Krish Sadhukhan --- arch/x86/kvm/svm/svm.c | 20 ++++++++++---------- arch/x86/kvm/svm/svm.h | 3 +++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 48b396f33bee..0fe60095ab67 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -56,9 +56,6 @@ static const struct x86_cpu_id svm_cpu_id[] = { MODULE_DEVICE_TABLE(x86cpu, svm_cpu_id); #endif -#define IOPM_ALLOC_ORDER 2 -#define MSRPM_ALLOC_ORDER 1 - #define SEG_TYPE_LDT 2 #define SEG_TYPE_BUSY_TSS16 3 @@ -683,14 +680,15 @@ void set_msr_interception(struct kvm_vcpu *vcpu, u32 *msrpm, u32 msr, u32 *svm_vcpu_alloc_msrpm(void) { - struct page *pages = alloc_pages(GFP_KERNEL_ACCOUNT, MSRPM_ALLOC_ORDER); + unsigned int order = get_order(MSRPM_SIZE); + struct page *pages = alloc_pages(GFP_KERNEL_ACCOUNT, order); u32 *msrpm; if (!pages) return NULL; msrpm = page_address(pages); - memset(msrpm, 0xff, PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER)); + memset(msrpm, 0xff, PAGE_SIZE * (1 << order)); return msrpm; } @@ -709,7 +707,7 @@ void svm_vcpu_init_msrpm(struct kvm_vcpu *vcpu, u32 *msrpm) void svm_vcpu_free_msrpm(u32 *msrpm) { - __free_pages(virt_to_page(msrpm), MSRPM_ALLOC_ORDER); + __free_pages(virt_to_page(msrpm), get_order(MSRPM_SIZE)); } static void svm_msr_filter_changed(struct kvm_vcpu *vcpu) @@ -896,7 +894,8 @@ static void svm_hardware_teardown(void) for_each_possible_cpu(cpu) svm_cpu_uninit(cpu); - __free_pages(pfn_to_page(iopm_base >> PAGE_SHIFT), IOPM_ALLOC_ORDER); + __free_pages(pfn_to_page(iopm_base >> PAGE_SHIFT), + get_order(IOPM_SIZE)); iopm_base = 0; } @@ -932,14 +931,15 @@ static __init int svm_hardware_setup(void) struct page *iopm_pages; void *iopm_va; int r; + unsigned int order = get_order(IOPM_SIZE); - iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER); + iopm_pages = alloc_pages(GFP_KERNEL, order); if (!iopm_pages) return -ENOMEM; iopm_va = page_address(iopm_pages); - memset(iopm_va, 0xff, PAGE_SIZE * (1 << IOPM_ALLOC_ORDER)); + memset(iopm_va, 0xff, PAGE_SIZE * (1 << order)); iopm_base = page_to_pfn(iopm_pages) << PAGE_SHIFT; init_msrpm_offsets(); @@ -1425,7 +1425,7 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu) sev_free_vcpu(vcpu); __free_page(pfn_to_page(__sme_clr(svm->vmcb01.pa) >> PAGE_SHIFT)); - __free_pages(virt_to_page(svm->msrpm), MSRPM_ALLOC_ORDER); + __free_pages(virt_to_page(svm->msrpm), get_order(MSRPM_SIZE)); } static void svm_prepare_guest_switch(struct kvm_vcpu *vcpu) diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 02f8ece8c741..b07765c278fa 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -28,6 +28,9 @@ static const u32 host_save_user_msrs[] = { }; #define NR_HOST_SAVE_USER_MSRS ARRAY_SIZE(host_save_user_msrs) +#define IOPM_SIZE PAGE_SIZE * 3 +#define MSRPM_SIZE PAGE_SIZE * 2 + #define MAX_DIRECT_ACCESS_MSRS 20 #define MSRPM_OFFSETS 16 extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly; From patchwork Mon Apr 12 21:56:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12198965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB96C43460 for ; Mon, 12 Apr 2021 22:45:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0255161246 for ; Mon, 12 Apr 2021 22:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343830AbhDLWpZ (ORCPT ); Mon, 12 Apr 2021 18:45:25 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:51050 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238085AbhDLWpY (ORCPT ); Mon, 12 Apr 2021 18:45:24 -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 13CMcnBQ170320; Mon, 12 Apr 2021 22:45:03 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=XM+f3CSviDJaAEMD1+a0+/9ZO+z3OpmRI489A5hn52Q=; b=kcGzH6iSJieDO1r5MWZ/eeqvIfM+o23+Uld3FcGH/0WM878Q3B+Rjxq4dnPMSgT+4/5h Rxo14QeAdWOPulRiuHlZLwEDQQEE42OIrwzVjPNppdY6ffP3i59JQBVo6U7XfnKgqRsR gZZEdhtY08myg2x3wfwyPTh6JEc8RnJZZJolMUFMK4np6n6wMzIB6FroaKMk7jOJz09f hMxNFeLjcVt/1MKsPj6My91bBEJWfSBLukzOHg0vjSRuSBeJscwnWPLqdRA3qX4eu7wN IclwX7evd3rDkVZp56TLRQhZyYL6g11CBAT67hmaBTeKAzo2xT5FixNOJa4THumvpJaW 6Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 37u3ymd9gu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:03 +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 13CMdc4G167396; Mon, 12 Apr 2021 22:45:02 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2057.outbound.protection.outlook.com [104.47.45.57]) by aserp3020.oracle.com with ESMTP id 37unwxy5sq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NsRzVNnKkEVdAWc/lyYk8xaqvWzrmNkbuI8PpSLGoMjf2ks7qv/gShhThyXfx+hUfbolSn7d3BJgO7yi6XljkXDzMypB2fnmrKwfYyXe4xuigWYeGYnIpIEPHXlrYNG4g79cuWfeiQneZoljN64e6GLbR8GDLZEFRQeMXe7v3h4fKUeJmQv22o7w05zDRB/stpQI6zE32555GGUuqFAm/wV+U0b+EZUXJdIflKIqM9WgF24W3rxKGXPQZDo3Qamh3u3oIe5WRcWSUQp+anGGI1nLCiS1Z0T6UhfshVIsIxsJqlDl4zcGIP1L6oURocv9gBQPbDl3rHwHHJRn7XzOtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XM+f3CSviDJaAEMD1+a0+/9ZO+z3OpmRI489A5hn52Q=; b=iqTzGSAMZXtg0fy6KnRKjCU8OjVKYMbKVg3esRmtiaDqGCAIrDrjG6xKpJLH9sno5g7tUHJfQumZpJKWwtooLUQD3lmaTSrvYjDs6yribrnVSZKy7PT6IS8uNOqasr960520uKRwJLtqCxAFreYM0XdlbHUkTR4cujxIQ0P9ymK+Qbti6nEyk3EVgce9Uoqgh3H3yYa06VftuDd4aiZpreiUfLnZrG6yMKRKlgWAhWdOlTNoyOPwZU1CFrpGH/qbD8i/TXevCJ7y3r8d386jBdqrWd/QFpMNWTin4IVEj6RIgGhWYsWrrA4LRtzOie+HCYNZe0uADcVtti9rAr0L1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XM+f3CSviDJaAEMD1+a0+/9ZO+z3OpmRI489A5hn52Q=; b=Lga76LiGEsEDKZFrDVmIpECsCyiNgqFbelKJAbMGiPxRfCKDQB0YXAWvoD1QVMczhCRC0nBe+o0T6z/QKbDnRxBAknCvMpjC0UM74hzjIPyG1eRzYyYAM1K1nKhASGML68AxXOaFIA0kTakIZ8TYcrijn0tyK4s6xXYgkAT6MCA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) by SN6PR10MB3088.namprd10.prod.outlook.com (2603:10b6:805:d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 22:45:01 +0000 Received: from SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44]) by SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44%5]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 22:45:00 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 2/7 v7] KVM: nSVM: Define an exit code to reflect consistency check failure Date: Mon, 12 Apr 2021 17:56:06 -0400 Message-Id: <20210412215611.110095-3-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210412215611.110095-1-krish.sadhukhan@oracle.com> References: <20210412215611.110095-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) To SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.201.29) by BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 22:45:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a588135-1265-4eb6-9075-08d8fe049b02 X-MS-TrafficTypeDiagnostic: SN6PR10MB3088: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OzcBDks2Dp1PECbEiM4b2LKXnL9JoGf/6YvXFQE4yMQYZakyVt6qPbAYmDI49gSmpAPH/NlQyGHLVI1bgZyLyg4FzcIcTy0OlPzt+LAfxWxGrv4/54VLHPjdN7NAdZjm4kHxnwpacGqJJSfqQyBgCEjoXv24rftYiVr418xFcdfsX2uQtrvVIVQEwnUMuKD66L8z6cR15WE5br5ff3u1KCG3QLDSTVXSHN0QpSusUOj/0BZWTTiupJoqKoe0iPYA5nBKJ2nDCOBaO315hO1ApmIY7+TCPEcCeg6UPP0+XZ97NIOSOiu0HJxUpct/AugpLZ2eEJe+o+tICZncP0spB3WNpbvCV6y49JNDED1F2PCTW0xbVEfCJBIAjFnnlz81Gy/mYrRmL4XDNRAJ9bj6evlJBGVE3gFD4ffP0W1Bvt82o9JCCQXN+4c12s/YAxaE2zrCx0tfaMqUSJn/JWSGaE2l1jTZ+9t/xi/teesJG5hJci3qB970GdzUJNUQ+dHjKeGK7pS9c/GsopsDLmdvnEyHumlU50i8hlSzthFb0S7PsausQ5Xz9pk0DfEXrqAs3ccQNxS0r3rIr5S/hlv5/gVTTk8UqDPovcZ29uvv14iF3x25mz+nqgwO/Mk/l8yEusK6EVzCMLFG6jGQJVOVcA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3021.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39860400002)(396003)(83380400001)(86362001)(2906002)(956004)(316002)(1076003)(2616005)(478600001)(4326008)(8676002)(7696005)(36756003)(6486002)(52116002)(26005)(5660300002)(186003)(16526019)(44832011)(66946007)(66556008)(38100700002)(6916009)(38350700002)(8936002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MJxTVavP5yXy7SZpN/6OkFul3u3/Uv1dy6h2QA5lOTezsRrkoYFJ8E1DnXK7mz+VWkLlUHPhIyLlihemWuRiFyQTCaBZpVq8n31m6phIEGtbPAOyFke7bexK14d2Dp43a8TmaLgRmzqmuxMVW17pMPyWMH4QI1LyGjo7K+4kauOSEy2jWixt2sUqPYqS7XWRU8lEezEI8TuEVFrVXPFmWJB9H7nzOISraMwsRwlcEG+O1aPI99k317ACz1KqrzqTa8kL8r+YG4nFxlD4WZaxvMrANrQl2kOnrHWPMfDranWzWehUDdJ5fpefg40S8Rkqw3YTPc5vmgLwB5IEwZ95//G+E/bmc6dKVOa8TCZVEjg6IzWyPEGLdtOTXpz/Jq4KyKbOLx+SWgH6cCaC1iJZjNLVitrPNGSeAd9lx16pQf+zv4P++QX//vZtLHVhIxCMttIcMdsdSmYuNJjZd5zOmm6uJdsn+L0lsTpTJjRAX90B7gu6s/yGKY+/Yjz5xAwJcx6B49CtOE01D2eANdwDa6CpVmoNQ4ARgGm9Qus7fa2NNkO7pwKSfiOSmLSGCjXasWxHpDU2vAgP9546xwilE43n8fUhMFfvRMEuIfbx4UqoKUeY8FVSKQ/jOzShIPeaqP5u8b1eaSu9ylfyV5YZBxNmLZX4FOsEKGlCcp0d3PLd160hZPQ2CIerQl0VsiZ/25qWM4oY8rF45r9qo5HxFdWAQTd8kEMguXttTuhjVnl2PStV18GS/uKM1KEEvc4uHWW70/0oAHIXwB+F4aLefAvQnxnqzCgTxUAbzQ9SuGa5aPiw1PtDTUd+XS0NefXrVZKPmsLk6qayisTzrkcAF7YWRPxNS8jzN+oZqHk0LQYm6/0IUvhqqDgnKpr2+lrsXgBedjQikoI9uqFqBOHoMATU29ninHhGLtweYEhFZUp3W349s90tB01/sTSUG2unJCOxRYK33XZ6phzQ6zsMBIBlEhAUHcSZaaAeL2wQmDP9ndSLYZX4PYnqHiqEDmCe8T/nyA4I4Uab+cKrLFrVonHX7txCJ1tkBMgKICwlX4zXY/r/r2Mx88FCQ2vkWOGARJ9/52KbU2LoQWhbgL/6llFbfcVSashjd7WSg1YQCP3DRjfDa0lPkuLlAWmGolFdAqUj/STxn37+8uzTHYc6uasJUV2gukUwytDnrWEKYUfOGXfvaPAwuHI+Aew+ohXsDhW/2HLzaCs8hMvcF+spSErf59MUcfwgCoT04bwZOQ7Jy9HuIJJd6x8sRm9nQcAY7/uMsKwyEBK6osk6d1EVdfCXgRaxKBusmE+QBnoOh6y3RhOqEkvR2kwsV2A+4K2t X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a588135-1265-4eb6-9075-08d8fe049b02 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 22:45:00.8944 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WBCBBAhukleSsD60/1P0Ng3IMvmnk4dQFjasXABEFNhkCU4qelIIwpWgC12Q6DTUwbkyKmTB93vyoVwKNtf4GvOeerTFrk1amKgqf55ESfI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3088 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 X-Proofpoint-GUID: ZvmuCfMZCuXK28KG1G-iFD5ZNUClWio4 X-Proofpoint-ORIG-GUID: ZvmuCfMZCuXK28KG1G-iFD5ZNUClWio4 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org nested_svm_vmrun() returns SVM_EXIT_ERR both when consistency checks for MSRPM fail and when merging the MSRPM of vmcb12 with that of KVM fails. These two failures are different in that the first one happens during consistency checking while the second happens after consistency checking passes and after guest mode switch is done. In order to differentiate between the two types of error conditions, define an exit code that can be used to denote consistency check failures. This new exit code is similar to what nVMX uses to denote consistency check failures. For nSVM, we will use the highest bit in the high part of the EXIT_CODE field. Signed-off-by: Krish Sadhukhan --- arch/x86/include/uapi/asm/svm.h | 1 + arch/x86/kvm/svm/nested.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/uapi/asm/svm.h b/arch/x86/include/uapi/asm/svm.h index 554f75fe013c..b0a6550a23f5 100644 --- a/arch/x86/include/uapi/asm/svm.h +++ b/arch/x86/include/uapi/asm/svm.h @@ -111,6 +111,7 @@ #define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff #define SVM_EXIT_ERR -1 +#define SVM_CONSISTENCY_ERR 1 << 31 #define SVM_EXIT_REASONS \ { SVM_EXIT_READ_CR0, "read_cr0" }, \ diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 8453c898b68b..ae53ae46ebca 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -606,7 +606,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) if (!nested_vmcb_valid_sregs(vcpu, &vmcb12->save) || !nested_vmcb_check_controls(&svm->nested.ctl)) { vmcb12->control.exit_code = SVM_EXIT_ERR; - vmcb12->control.exit_code_hi = 0; + vmcb12->control.exit_code_hi = SVM_CONSISTENCY_ERR; vmcb12->control.exit_info_1 = 0; vmcb12->control.exit_info_2 = 0; goto out; From patchwork Mon Apr 12 21:56:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12198967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63C09C433ED for ; Mon, 12 Apr 2021 22:45:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D37F61244 for ; Mon, 12 Apr 2021 22:45:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343831AbhDLWp1 (ORCPT ); Mon, 12 Apr 2021 18:45:27 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51626 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238085AbhDLWp0 (ORCPT ); Mon, 12 Apr 2021 18:45:26 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMe6Qi178913; Mon, 12 Apr 2021 22:45:04 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ewWFL80mcKx7aXij0/rdj6JYFuSJ8G9GgQlNh9FiUe0=; b=ivRGa1gTrZo5ra/69t0NI1miRZcvJKofFHbVhmtD95XvBjlRbvJfzj5LLwSqtp5X2Sbh Rs4I5hWulEwf2INGYGfKOPmMBKUtfBDvOGDApA1xSQU2IOIX0BsIZ43x3C4gpOe2s9pz 1NjnAB3BXEheQRnfO7JzyO4yRHlqp3FkH0RR88qm+wnXOGFqOMPtpgRriATvnUzgVHAh BtPkcmgmV+Aht6ZKLI0kMzy1IDjJDsD+KQrwIxX8MnLTUVOploHdaZH/20SMSVkdnc22 mELc6q5oEy+FAPZXwLz/Ao1NxZ+VC+hET05DBe+MsSFpujeC/APBwV8OoJegxY7yGCiM 5w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 37u4nnd9nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:04 +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 13CMdc4H167396; Mon, 12 Apr 2021 22:45:03 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2057.outbound.protection.outlook.com [104.47.45.57]) by aserp3020.oracle.com with ESMTP id 37unwxy5sq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HMnMf8BHZ6S6Gvo8fvS0k19iexsAUwwfWX7W3gtOh8WgcVXsTj3Kzm07P02wAapkndQs0vnl06/1jJml/TqA4TtrWn0OVoqTVJGd09bKujZY+uhbdaHX06QQiSLCPQIdn0WhBGbfAzZvpbc/1BmUakztrXRWUgPg7BD2WSOv03TIsZYOXFm3gg2TWDT7x0dq3cJGUL8pRTAhXeTpbGeRm5Pld/yMlKho0yydgKivSAfeR2AIpPrwOIHgbrCQggpojarK3qvolDj5r96vX9c26uMKMfU788iuo4DoF6AOpWqH6xQ19/tfPrf/2I2Ya3NFcU+9aVz3yb9PNTr71dZRBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ewWFL80mcKx7aXij0/rdj6JYFuSJ8G9GgQlNh9FiUe0=; b=AjO+uNcRXY/ezn+/w+ILHhTYpDHCRrpS6zg2yUQpzCCB6ACo2cZ8e2sDUtEOauHVSYfiUMITSHBcnS++fPiYk2JmaT40Ig2yeOO6c8wyklN2saTybOs1qwmiTF03Mn0O+DtTHzgSMQLlQFZSCSyj1spOznUhwOUWKAUBEBLO6GeoPv3TL6ZazTs/8iZiuU1I1Ee3v8lCLSOn4jz/T1GDRHeUPPJuS5Wch7gnvFN3lBjug7U1GVYZPeGz2Bo5EwBO/Y9GwSX6li2PdI64/j1PSruhofian+idzFkN5M90Shsu5ZGGWIRfrlUdp2Tzj+xTBcEc14nfo2VLOp1Z8AJudg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ewWFL80mcKx7aXij0/rdj6JYFuSJ8G9GgQlNh9FiUe0=; b=lUPokUWWBbon854m/Q8hDGPUqCQQDVf0CIrhdjTBjWMLgHklTa0sjIzhaDUPmzxdjeQabfEI/akioWhIr2ZrKVs62zrC8lRMJ2bmGEaL477Xn4UeXtRwpHes+oBvg27ULUlhorzwezVZUyUPn7aPZ1vV8e3DRSZ7xfucQZEl8dE= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) by SN6PR10MB3088.namprd10.prod.outlook.com (2603:10b6:805:d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 22:45:02 +0000 Received: from SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44]) by SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44%5]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 22:45:02 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 3/7 v7] KVM: nSVM: No need to set bits 11:0 in MSRPM and IOPM bitmaps Date: Mon, 12 Apr 2021 17:56:07 -0400 Message-Id: <20210412215611.110095-4-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210412215611.110095-1-krish.sadhukhan@oracle.com> References: <20210412215611.110095-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) To SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.201.29) by BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 22:45:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e3fa259-4767-47ed-7bf9-08d8fe049ba8 X-MS-TrafficTypeDiagnostic: SN6PR10MB3088: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jsTiwABmYcS82zxLI/YdGbUm18cUX+us/gXQkr9dPrVad9Tvj1fsnORRbDmVSKsffwmRTtcxu1ppv8Zva/FrtPe1jWbKMQxHrLvEAnGV/qmqtJ/VwRgYQmr3fNOgBg4yNYHjnaGY8NjU1KIVfQGphUZ4BlyUT4gOeURLxWtVSG5aNyj1RVelmZiUefQVUWHOC5Tn3eo7N75iqLtUsVCvKbnVBNQBb9tvCTvpkXwTC1zvBJhpqqPBoPg0u9VdCGPOq+UUl+zmfJ+C70FHr4C9wEUIJSB6k756+ZVWa/yFRuVNM/XgPdu8pOpBrUylWhglH82lxiE0ZpHPM/tDWy245ejHfZWM+eCfAJPA+2AYuO0eTZ1mXgwyoaFsBdru7n27/FE4AHlYmnXz01DJI14pFQzepktnJSO9kMJLuHrZ6A1GdPnk80YKUyEWxf3RRVUshjXOVL9iwWf1YbDru5RPMazwRUncZPBiKkipUrEhXeR6Xto4TdiJYY6gaT6tkOpGrsCdcRtoEOhLdm09w9p5J9CBpPWxsLQbHAs4yFW94JZwRhZU27wIDOjZNMZcxePGLGAy9LprKaqM/PQYQXg/FT/dGXzpui+L6HveKEIL/Ok9EpX92fTVtArCfNK7pObjK41gHAis5pWYcOX1NOKZ5Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3021.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39860400002)(396003)(4744005)(83380400001)(86362001)(2906002)(956004)(316002)(1076003)(2616005)(478600001)(4326008)(8676002)(7696005)(36756003)(6486002)(52116002)(26005)(5660300002)(186003)(16526019)(44832011)(66946007)(66556008)(38100700002)(6916009)(38350700002)(8936002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: zzqhdPkCR9P9CogZlmM7iekU8uCBz2tJUJQNgsWi4UclpN3ZaKD2VhW/bS1O+EYsVhrhVLmWP2Bh6uOgXwwTZY/pgL16Kh0ML8AHyWNGZa7EZPEMFFknQh2aVENZVISrMN0CNKriPJKQfD26szGTAIErEmKtIzsrcVWH/KXVn4XUQMq3pS4ONQQGHIDf4+FbIW3ggO7k6XJGBKdgqTBs37H1CSqZBWQnQaZDADSLS2nx915nptO3vS/TxYHeASuaCAfHH+9ELpqf+hh2fKkssfGBROPplpx/nDur4DY79xAKntaGM6RtqIUpHZ27E5Y/07yhhfxWE/1vAugqoAveLDvBUC8lA9Z1X/FDL4KOZR11GeW7KoRE4wHHEtEJrMyv6r8D7D+VH5nz9CuKk6EsN/27TXSqSNx3aWXnA/dFO1LtO7mW8X6uXuiW/1Yr/hMtRqJ56mm7hP8f+jKfz5WDee7PPs23WxDMFSHvxpdm/flO2wveqbkT5EaqG10wa9oWWavb9zAqj0ny0tXrUmYszFhpnHxz6XPUWBB5ix8HdQJs0y7azgD1qRcFq/R4sEid0/mx2LQ7lMpv1kyRmCv0B7CgM//pXZbME+PUdja8E1sD+hSDHutnJBa2CqY55YX+x5LdNsH2R5tvdBnTAg7mKM66BuDof9gLzadsoxI1hM0IpFheR4ssMbZ7NYXjsBCkAS5RS0a063oWygrr9G9pgazxskSA7FkV0OZQbFADKaK1rniw84se9zcITwHOCbVLw77I2+/tFyoxEGvS/9azElhJxC7hHnHHf9BCDCB3Hu9pjDlkT2frSSZ9GaPYSF/dBnWbABqrRasMEwiQBsZj+DBf1ik3ibTMPRbCzPcE6EgYLtBDMBBNdvK/zzXwnslKbgwrj5U8h1CrWEM1FgPnTw4Sh/lgvYUCWl2TYAD7IUXMq0m/q6HM4xc1/CO9RNhxMOliqOxxv9Wyn915DG8uhmx9ZY1hC1nd056B9z9Am89RpuIwpPktDyp4Bv59/sje1ULXL3sxbtPp5pA65tRAU4TPine3Fzd247qANTWysD1ByvwlYkUaQYBtvkNsbUcrWKtCaovj/0R+XC9lnGTRvO48mH6lP6XkPtgbDIEXqYdiWiUVnv6nOydV70mPmIJD8kCqnNuh9bDANr7Bd62dnHPK7J+hebMCAwwdqFDJ9r5OnDEt82LTPbxMmP1+Mh1aRuyEtD/bIY318jQSCt4pxzBt6o0bSyKpyfQqANWNMqxhTCpWkdVWgavdhQwTyjrxar1sgHHB+3TQc6zh/uNbc/YZ0NV3Ks+93wE7/s7zl2x89brsE2qHauI9MNF0jrpG X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e3fa259-4767-47ed-7bf9-08d8fe049ba8 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 22:45:01.9748 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r9pjQAXAA5CSQp6s/IOVOSkBw55FgZRwWU/yP+XTPiL41iWaRmARe14uEgA2M2uZwapHyoH2cFNKcQlx1Z/hbDAIIzk0otevNGk4rhlEnsA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3088 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 X-Proofpoint-ORIG-GUID: N3Z4gKpwgZvhL5FXxemnPXmo0tyQL7kg X-Proofpoint-GUID: N3Z4gKpwgZvhL5FXxemnPXmo0tyQL7kg X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org According to APM vol 2, hardware ignores the low 12 bits in MSRPM and IOPM bitmaps. Therefore setting/unssetting these bits has no effect as far as VMRUN is concerned. Also, setting/unsetting these bits prevents tests from verifying hardware behavior. Signed-off-by: Krish Sadhukhan --- arch/x86/kvm/svm/nested.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index ae53ae46ebca..fd42c8b7f99a 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -287,8 +287,6 @@ static void nested_load_control_from_vmcb12(struct vcpu_svm *svm, /* Copy it here because nested_svm_check_controls will check it. */ svm->nested.ctl.asid = control->asid; - svm->nested.ctl.msrpm_base_pa &= ~0x0fffULL; - svm->nested.ctl.iopm_base_pa &= ~0x0fffULL; } /* From patchwork Mon Apr 12 21:56:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12198969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB226C433B4 for ; Mon, 12 Apr 2021 22:45:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDF9D61246 for ; Mon, 12 Apr 2021 22:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238085AbhDLWp2 (ORCPT ); Mon, 12 Apr 2021 18:45:28 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51640 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343834AbhDLWp1 (ORCPT ); Mon, 12 Apr 2021 18:45:27 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMdots178396; Mon, 12 Apr 2021 22:45:05 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=2EMn9uMFXeNgQNiDVN4wYZm/Gnofl2uKwEUkz2ZMcuw=; b=luD9/8Ww5ALEuwPTH9yZH9UQ2f1l+Chsw1gbQg04TjwcTaolQL6Ja8e0gylnuN34+lQn dacRVTKfrANC4BTNZGRS1A0MHyFXPlXW1XBYQWR/XI6Hym6zs98s+xrrpIoA8PWqpp1v xcbbMR7IDJniFZXsJmfKYF8o/R4U5xjm5WQTG+cYwpkBzhFW7a2Gla09rtx4k5CbHDvL ObsnUMdQL7GEBDSyA3YTZVc9pg7uGq2SumyK0bmhNIXyMncg+NoJkLL0wNxrqVQVaWad RcvW0Vtr40l2/wrtcWZZj7zfDbFx2TcOVl2cxNt+l2DWpBKRLOeij55ov5SQe9iXxlkC ZQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37u4nnd9nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:05 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMfR7B009071; Mon, 12 Apr 2021 22:45:05 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2056.outbound.protection.outlook.com [104.47.38.56]) by userp3020.oracle.com with ESMTP id 37unsrhcft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wz49uRnYwBN2cwMKmXnj9cJNE0Z/L8BFbL3qTgjgO93TNKaUBVeM60EEIV/acVzmS+W+WKjKoamKSDQSfi0HaMf7kV3AiD2MUVOctRHWLk7OfhiFAkwEFFW4cJSFIbcDUuDgvYfdESp5Tl1Hi4WqTjo/JAwmDmG5Fnh8B09rvNPKoVdtD7TGCS9vSrmQWwW1vhworS5LwVsvzBaq2SmeoW6A/0Dmio1rTWWlArppz6HARkUGlJTBoGQy/qKIj0F09xoKxOZKwqtXtTcrs7c/3gQGla1am/uj3aEiQNTeQje5AFMEjzKbta5bgpqbjcS51F0iMfOOkgeU8Ert5SrV8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2EMn9uMFXeNgQNiDVN4wYZm/Gnofl2uKwEUkz2ZMcuw=; b=fDGegYdCfxAh4nIz1RQtVlWQ6LxVG3FxAxEX4WAxmh7QRoEkNPOJ0UqEtqdiV6MO29RYin8SsyCjyfO/QAzST1XEXZ/N51gxn5KlCrpAi8dL2HXuVj7iZdKzbfx280ud/1OgMwChEvva7tTnF3azzDDWxyo/vFMtA+8dOWueBZQw6GrjXe71OkH4+N/d4dEKahL+pbkt70MLUb1dDiRz6IMoCbfGfKcQyek72m36gqAlWLNMynxGDfa/n1KeGB2pluSdAPHTfMzg3KRtPPnUiTRJLN96Y16RHtT/gYFpILlJkLCW8hoAeAx/7xQc2FiVeBVSq0Exoqm4c9L5RNOOIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2EMn9uMFXeNgQNiDVN4wYZm/Gnofl2uKwEUkz2ZMcuw=; b=B0hcKZdW6qKRRVMFfEv6NUGoa80Bf2BhuoLYatQUp1N5vOkvJpoOIzs9ShyXo9nzTxT6CXTLWEGDNBq5KVu99VWw03j7PefnlqLA5HHBcRSF1Svo1In4UTL6GEzWpXk4UxBYRQLlqO9/qm8lpQ4EUmkqEwmgTfdlcE9Z43RnALc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) by SA2PR10MB4683.namprd10.prod.outlook.com (2603:10b6:806:112::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 22:45:03 +0000 Received: from SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44]) by SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44%5]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 22:45:03 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 4/7 v7] nSVM: Check addresses of MSR and IO permission maps Date: Mon, 12 Apr 2021 17:56:08 -0400 Message-Id: <20210412215611.110095-5-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210412215611.110095-1-krish.sadhukhan@oracle.com> References: <20210412215611.110095-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) To SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.201.29) by BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 22:45:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dbfd420a-f913-4729-8a17-08d8fe049c50 X-MS-TrafficTypeDiagnostic: SA2PR10MB4683: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qJopkmi9VaeJ/F7xXLwJKxj4j/Q3khmKx7jiOly3MvTYOtd0/qKrccM65ljKlTLEr/xbiL0hYseghqwQqvsYCUIfRNQD1vYqwvO6rv9GC3OoCQeOWmqf19/Dwv+PFwEyk9aPWkUy1dizJNX8590BH2nc23ULH3Mo/UaYVYRZzHh6oWz7Sbq3QL1VJnqLqUJ6+KGda1sPPdXReZ0aag267H84S9gxQhZ6Vs1BQqs4I222pZ25JPCDakfz7lxSMrlkgBxQeNCO/kJNPEml8eipxyQvCVpgB81ne63Pb349j/SVB7JmRZN+TSBdxhZnq1IpdH61zztTjqK0VfCQcw9RCwNgoVHVZV4wFaxEnf+Mp7IxHeHimR7x8kEEueQxnNGjQNAZZk6wzKF8SoznjPbxwgygOlFPnBdCMulwUbvK0nxjG/8D3ZMulU7icq8yfcXtYBi6xeLD3CWrhGLyys/fqPn3Cg1I+FgSOnl8eRymsFhLD2SrBRNOGkLIAoZp7ldjWT5Elf8JAKddvA0pIh8Ib8gCYH8xxzl5bUUwl0e2YrniopcwbvTdXgFklp9utQogdsGZbjvtu5abI7hTRoRFWpYbfVse4Nj7bjBf+cIJB7cJM1sAdu0WzAwFnNQTjmuFKiOO1BBQS7i+V0PDfgZJfw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3021.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(136003)(346002)(366004)(396003)(39860400002)(86362001)(1076003)(186003)(478600001)(26005)(6916009)(4326008)(8676002)(956004)(38350700002)(38100700002)(5660300002)(66556008)(66946007)(2616005)(66476007)(2906002)(52116002)(16526019)(8936002)(316002)(6486002)(83380400001)(7696005)(36756003)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CKBZrMM3/nCBF8kM31+JiwZTn98opi6AMFeFRAPHqGyqROshyRKKC6SOrqIldk/6CaY8vtwnn1P1Q5Lsy9kGp4XBr7JpCKn2fEogjPDa20Z0vr5EnfD06g+jaDKOV4xRAeIxAe9NN33fKohMpwjJrFw+3/vm+UosH5F7pUdmFfO12jFTj59VQ2yJBC8sWa/IMV13/a4smynnVzV6z4SmgXSozmD23pbieI3MPyznnSRPoFp18HvESYRkoFvZGbo7PodHIuMVleXFei7r6mUQXxLE3I+VVtCsvr6ooz2QzaGY+o25vewQyskW9lIsxY84J4ts7nqy0WriUwm+rqFDDS8XCE0OOxFw95XxU+rk8foFywI39ns31XoiUX2O5VEWdSMRfuhqg2W0yTvuyQqpntP4umsqykEixUA29ki/alKonF/hnoNbCyG8Bc41oV6i2iaEZ7x2sO0mHRacBq5fzucN40UAeglhi8OqOpcU8ROXzhoOP512ausBI/oKZPwwG85ocB1bS7LOmAsurRnq/QeUcDzqxxi113YltYWq6mvocI7BmhxTW/2HOhOGBisgg+9TMRK0dAdpCE+SU2/M/MTwVS3WqWFqWtAZl+/A08tvpR/Hj8meJizz9Xlle0yCHX7DpqtNXDgv6MwotjP5m8tPAxJc6VwrgG3zuj/xsPohYA6gCmBQ6H4HU+vS9EVHPP0nD4XOB4+kec9GjwBw3HRtZnCjwj/oD6bpPWHXOBQZcSvkjcuSmxYw64UbypOHqyflX0EbHKyBWjKXja+73UZhDUBRq+Xdlr0mgOq9mTkNURJbJxJ35smkBeXGYijbkNGfB75CbvU/U5XsM/7BBDVepjrDxHeZckVhoElEQmE+YwJ8y4WhCqNxuULd8791duwfQmU9exdDz0ACj+3FGLLYmI2CzOEsbBKAhywS0X/XYzMnjvEaGSdzlCwVtrrr2NDWkijFicqG9vazE1DcQitweJTtjN2dsCTp/vPba++5COiLAO8gAw2WHt/p5uFjws9FziM6oIyzgqDav0XguLjYEaEOGkVCwvanNwFwvLYe3f5K7IkDtzTVEfCOFm26GDotQTo2dUMZbsO5IKeFyYifkRyOmvTfc/RxlB0aJMyWrCAlk3IRCzUQMtv+uXOIM19O0jo+EcOArnNMMJDlMDJFUUcAXZEkAibgeuQZLhp94LjDeFY3DWR6la5sibf50Wx18B+IsuILIw1416luJR+UdBMg6Ad3EcghOLXr/v7nev50/JOhUPAkrx5IPO541Gk4WjeM5pF1lInhFHXWSB64AKVwTg1VK4caMLSX/trbSlYShCxuDAI4SMwYvIGv X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbfd420a-f913-4729-8a17-08d8fe049c50 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 22:45:03.0632 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MPFQaqH2viQAea1yIpq2nGy8jJ+yTK51qd/eGxhLg8hds/Wt/si29TxZzbgnf9wCP7J+IdS+SVSEoA3Pf+DuxtwIk52lOt8ui6wlyRNAnMY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4683 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 X-Proofpoint-ORIG-GUID: 2nx2ij2rwEe-1eL-VVyiB0A4TWjnGDT3 X-Proofpoint-GUID: 2nx2ij2rwEe-1eL-VVyiB0A4TWjnGDT3 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org According to section "Canonicalization and Consistency Checks" in APM vol 2, the following guest state is illegal: "The MSR or IOIO intercept tables extend to a physical address that is greater than or equal to the maximum supported physical address." Suggested-by: Paolo Bonzini Signed-off-by: Krish Sadhukhan --- arch/x86/kvm/svm/nested.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index fd42c8b7f99a..c3e5f4e7c987 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -215,7 +215,19 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) return true; } -static bool nested_vmcb_check_controls(struct vmcb_control_area *control) +/* + * Bits 11:0 of bitmap address are ignored by hardware + */ +static bool nested_svm_check_bitmap_pa(struct kvm_vcpu *vcpu, u64 pa, u32 size) +{ + u64 addr = PAGE_ALIGN(pa); + + return kvm_vcpu_is_legal_gpa(vcpu, addr) && + kvm_vcpu_is_legal_gpa(vcpu, addr + size - 1); +} + +static bool nested_vmcb_check_controls(struct kvm_vcpu *vcpu, + struct vmcb_control_area *control) { if (CC(!vmcb_is_intercept(control, INTERCEPT_VMRUN))) return false; @@ -226,6 +238,13 @@ static bool nested_vmcb_check_controls(struct vmcb_control_area *control) if (CC((control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) && !npt_enabled)) return false; + if (CC(!nested_svm_check_bitmap_pa(vcpu, control->msrpm_base_pa, + MSRPM_SIZE))) + return false; + if (CC(!nested_svm_check_bitmap_pa(vcpu, control->iopm_base_pa, + IOPM_SIZE))) + return false; + return true; } @@ -602,7 +621,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) nested_load_control_from_vmcb12(svm, &vmcb12->control); if (!nested_vmcb_valid_sregs(vcpu, &vmcb12->save) || - !nested_vmcb_check_controls(&svm->nested.ctl)) { + !nested_vmcb_check_controls(vcpu, &svm->nested.ctl)) { vmcb12->control.exit_code = SVM_EXIT_ERR; vmcb12->control.exit_code_hi = SVM_CONSISTENCY_ERR; vmcb12->control.exit_info_1 = 0; @@ -1250,7 +1269,7 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, goto out_free; ret = -EINVAL; - if (!nested_vmcb_check_controls(ctl)) + if (!nested_vmcb_check_controls(vcpu, ctl)) goto out_free; /* From patchwork Mon Apr 12 21:56:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12198971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA5FDC433ED for ; Mon, 12 Apr 2021 22:45:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B11261246 for ; Mon, 12 Apr 2021 22:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343848AbhDLWpb (ORCPT ); Mon, 12 Apr 2021 18:45:31 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:44596 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343836AbhDLWp2 (ORCPT ); Mon, 12 Apr 2021 18:45:28 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMewFE083254; Mon, 12 Apr 2021 22:45:06 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=P3l0o2q8uHM0C97YI5Wc+JWEWcEFjZX2qoPwXMKbZrs=; b=fExadP8HwzqzQ0qyAGKfFtaaBfyjLXHAnFpvHIxqEICRxnXYFgyOhI48QM7UqH8cbqEl foPwW9obbd6C1HQeMkeNMl88wvpuri5/DroidMc34g8Kp94vtFPvOZMVkiLn4QAxc4W4 FCcINxV/5vbutUPwM+e2OWVaKNqZnzVwcY03h4glOIA5f24XUIrsaEfoyltFcIBgKtsW X5LEy5kEvZ59V+CF1bRSAIpqJmBOj88MTR4FHJkWDk5mOlYALBLqheiPwMu8c/fNPkHe wMZwCx8SflECXYmBbBOGyOEcSrRG8J9uRGAxFoBzHPVZXChS9qqTER57N6DM9UCl7AcC EA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37u3erdbdu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:06 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMfR7C009071; Mon, 12 Apr 2021 22:45:05 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2056.outbound.protection.outlook.com [104.47.38.56]) by userp3020.oracle.com with ESMTP id 37unsrhcft-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KTHLLUuSe98IDr5dRHMFJqFgjncTuW+PEd8GDIN0IPpEolEx8Nz0i6B9Z2wh6XW4/o7PyOFU4PuXi6wCMYOTsDvGptlmiSKz9i2diy/NUDT1NSjsRF6Uuyke7lJUAhH54OI8oM/Dhg7IgV7ATrD8Dh9Ex4jVZI+Nn7+AMboZpXj0/MAeI5bvELOfXpmA7S1Z6AvEWFrMsC7tXWvFLWOF13cUHzU24Hh4WXZAMq/3wi2PrUZ9IVjfRqUq5WiWzZDQ6MgIPhkHncfmM9Li4kPmDbFrdrBLZi4YG8Ug58RJXo1ZuVEpo7OjbP30VVp4ZPXiORWGgmlc6GBN/qSlJZes1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P3l0o2q8uHM0C97YI5Wc+JWEWcEFjZX2qoPwXMKbZrs=; b=IQM62Q6Y840ouBKJxlQuu5gl+qLp177x4MNhAfdd+Go5gWlSDLjESEA0nNEzqwR7z2SOTsv7PXQKuRhvBl2KYzjVg20lkMfyTFOqdOhgzAwmd42Cz4fWJpsF7QAXzxSY4a/jYRe/RyriuA9RAJDRcVunhCUAgrp+RxTuB3Oo+DPEI5PgpL6BrGnqeYU9vWLWzyFBTX1wjr1mTWodxOq1GheOGebzV+xvIm0VKk7KusqViAAoNy3ITIPxMqm208i8proMsAXcBurdIc9XBLsRrvI7RrrhS82QdlJPQYkfrMi3G505bPp/pZQTk9J4nKua1OWu/hWdC0XwDibj+E1Ulg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P3l0o2q8uHM0C97YI5Wc+JWEWcEFjZX2qoPwXMKbZrs=; b=ApJdx9brfaOO65e0HrYkArgWwgZ9B+31v2c7F38WDqjGubjPeIqHiH8Pd2UWTwcF9Pj2Ab7QZD0b04FS1M5icRWvpMgS5Lfcrum/4iqpmovuZOl97xULBCitYiYBviuOml2TEaaPf2sXHkonOL1wOTGpuJtp0rzReYVox/+NtWE= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) by SA2PR10MB4683.namprd10.prod.outlook.com (2603:10b6:806:112::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 22:45:04 +0000 Received: from SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44]) by SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44%5]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 22:45:04 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 5/7 v7] SVM: Use ALIGN macro when aligning 'io_bitmap_area' Date: Mon, 12 Apr 2021 17:56:09 -0400 Message-Id: <20210412215611.110095-6-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210412215611.110095-1-krish.sadhukhan@oracle.com> References: <20210412215611.110095-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) To SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.201.29) by BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 22:45:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b0f3b61-bd1a-43b1-5fdd-08d8fe049cf7 X-MS-TrafficTypeDiagnostic: SA2PR10MB4683: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:296; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rtgC2b9/yP9o8T3CrFJnOviWnKJQ3NWV92LxRoiPyQbHwqDBoxNrGOfP5S7al6fXNrKlc+A0AZ42sUNT7PNLHF1FjqT4WLs8x/7bwW8rmlEkU+HGc6DXETcSsYHUTUmUelmOlxpKdQvgDks+AensOzizs+Tsw+FhVeEPXaqQRKKFmfAxUJ10+lvyOatXXQhBLMeNzms8PzLWGIj6smL6m0P4dRVTZdbN2AwkUHlHMRWIoZo0urvmXT8NGQ97AoutkUw6X3kedpfNm2Z4Wm6lHM4MHeaf7a9mJXAFtgEdxJrPQ6/b9gpbUbGBHYr4xUQkpruXWETV6sdUJebC57npWXmvs460o0+O0UPIvx8GVl4rdxG9Ia5oBipnXvUme+Pal8e892u/syCpTvrlfeec/w4lES86+okIYVmgrgjvdWY8RpG+3hV8ZMiypT5yD6AWzf2M/me9jjLpyEtJYF4iB53jaJCCZKXLjSOlJ26rhjNH5gNFjeDDJNhaY8TgHraXGxbi8crlS8tVEQXOvXpROSgXVG6ZvRnTPkEV5q0o9LeXTU2N69NQXMfkBs57hJhMCuvAYYHliUbjBM0zrF92OYxyyxsi/IAAEgQQtER9t6i21hEXm2QfSOLLCQ6lyQNvT5Ji2foseJOijRyAs8thFg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3021.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(136003)(346002)(366004)(396003)(39860400002)(86362001)(1076003)(186003)(478600001)(26005)(6916009)(4326008)(8676002)(956004)(38350700002)(38100700002)(5660300002)(66556008)(66946007)(2616005)(4744005)(66476007)(2906002)(52116002)(16526019)(8936002)(316002)(6486002)(83380400001)(7696005)(36756003)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: J9kwUOxkwiVxMPKgyO5klojIud0mPjG8SdES3XN2CYiwp85WwufZ+I4wFDuUdHMkhvWNFqhEqzElNQs4/695odJRN107Oqx9Ty63lRlpvpeka56EiitHQX7Be2fLmL+rkbeoTzZcwyqCG6MHxBa7J/vBrIkaAgJbsUWBydzV31BRowQL87M0/PRy3t/1RPJ7ys2bSp5Mod4Hw8L9SwMQ2f+fJpyahySF5ATwEtvvJZ5ueIAOWqaXG+I4Kj4Kq//4G5at/fDaXXQd+dDfYqr4PLpmD8M6mewzy3Xzcphmpp8KxHrw+/tyFv0DGLrUyaWt6M4bEB2BB5PZkQbryGvhFhzTf8rnzW2Hj24Lusc33iJQxRvlrKzzfyCKee68J2165ilknvnGMNc8VdeniadNZbiYBEAE/cG152/FyG4YrYpH6pz+jtgndIl98kAz+YcmMUNjSOiBkNcdtPWXcYo3MQqGm+gkdIIrbsAZQtTeiwRAGEVbuoFWA1BpVOoZjcO39qq2Ox9u3aJocoGQS4kLzghnV5DsRtBsQ2TWxpsHgWyDMbFjaxBdCEdGj7BvYEdHaN2Pdcl6caT73BDmf6X0m9nyjb+XQKlny5mZ5CxetZZsKGrTiomzTQwbBY8kklIHyIr6W6GeE4sBf8CdHO589svWtAeriT1O+nPIunaOkxW+D+G32MgAv2EJZ4ouM+1fzsokRAfxMPb7pN5mMst+iQanEumD/IOq/x+isT0sS3lOOoy3dw2SfpdtCusJA/OUvC8qqVCmp04k28EKQ5r/1W0zoWvFN7CkmAJACQQ8zXJPL22Q8Hrfb0B7ApcaCwzsj2SfAayoBs3BhucOmUsBEZGwn3ME/ypraejNNfNT2UC2xDoKc2WaeeBkkKAsoNtpDsiTwuILXlPM3ElanOYAml0U9siBTKxelb5Tctsk0AGilfPvQ1wpmi89Cb94i/Ad8GgzAZ7iINtMahefdvNg0JBmwbmkJuudNM9D+JLS8qIe5yH7Fml9+bG7zn4Nb3XYjQAyxU/ffD75GANfQzymvCMUgW7s4DIu+piL+kP+Bnn+EpelvFxbMz6WaSLZoD33ppMeEZQEPPAhWbg8ctNbpQQWd80WB0GptZnjFLHf4rKS1rcAfOyy2Cu6DXsc0/hRPsi4jUx0KUFv2OH1ZKdcG9NPRhxZvIDKBh+QdD3rPlhVx626qruCo+jj0cQ2tHPx/Amv2+SmLdVTu6+ET6lvJXJ66tFHkRtnnlE5E2NVG2EdnXRzrU5Eh08H4QJhIHNJMBw6ikgqVzLmLqTzhrntNbo6+OKlDU/lpv65/wUt0Vr5MbSlrIUdnf/ezb71Ru4W X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b0f3b61-bd1a-43b1-5fdd-08d8fe049cf7 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 22:45:04.2435 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JjvEUa5Tqa2/bqcrwZpD3AAE6URUXjOA/W1LfJPoX+4SkLrR7I8xpkgUTe1zb51UdajMY7LJMK2TZCYubK/UabMtYRwPJ9y6vUSLkBh8U+Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4683 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 X-Proofpoint-ORIG-GUID: h8Zi2MfAybOly2jnJQWNg-m2oVUVP0Jg X-Proofpoint-GUID: h8Zi2MfAybOly2jnJQWNg-m2oVUVP0Jg X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Krish Sadhukhan --- x86/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/svm.c b/x86/svm.c index a1808c7..846cf2a 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -298,7 +298,7 @@ static void setup_svm(void) wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_SVME); wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NX); - io_bitmap = (void *) (((ulong)io_bitmap_area + 4095) & ~4095); + io_bitmap = (void *) ALIGN((ulong)io_bitmap_area, PAGE_SIZE); msr_bitmap = (void *) ALIGN((ulong)msr_bitmap_area, PAGE_SIZE); From patchwork Mon Apr 12 21:56:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12198973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7F97C433ED for ; Mon, 12 Apr 2021 22:45:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B26EE6121E for ; Mon, 12 Apr 2021 22:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343846AbhDLWpf (ORCPT ); Mon, 12 Apr 2021 18:45:35 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:51076 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343839AbhDLWp3 (ORCPT ); Mon, 12 Apr 2021 18:45:29 -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 13CMeqXX171561; Mon, 12 Apr 2021 22:45:08 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=Vdq0sfvdZQvwtkc9zPZeUijbgZXubiWRlIgEczIcQCM=; b=Ypnt7Gl44rmmbG3X+1yJKTOaXz4w24wACATIOvqO+q6m1XdCo/FgqQuxvN4DgWHm3yRD zqi8gcrQhLZ8Avh0aB87PBXwBbcat90TNN2a8N8PuICTAHjDbETN6/CWvRI2w0p+NcBo 3TPiuwsDJPJ9ERZ2m8NbYJmiYfSt6OEQJWeTbq6bxluWzlYluQ5399GI0B7PRvSi9dWN 00HwBYTrQGjhIgfNAupiGXQrpOTOiG2bkh+bSdVSDEcSeSyyD5YGzuD9LqOBUm0Yhsd5 dPsxn9XfdqJ5Vlp8/EA1PGHH30PcKLXJ8KiyQMEK816lduCR/sq5aWXmIC7AdrqkjgP0 ew== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37u3ymd9gy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:08 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMfSgJ009379; Mon, 12 Apr 2021 22:45:07 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3020.oracle.com with ESMTP id 37unsrhcj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tt8GuyY+992Dbz1RoMeTBcT+nqcXn5Zbn9bBVzRMUlqlSee94BucfTWa+//ar8TwRTxFXQ3F2e8ckXKkhMNbIe1DJmsMTFauXrVhHGjaH5I3XYCV7vzUt6/pqZNtcYk98au217KY/W+qH1DQLt/yfqbpb+yDkgqKK5NGE7SKeJy4TISmXzl7tPOSGrSRKyd+QepbPdsB2P/DvLD6UXyH3bT7eKwAQe4m2WraVZO4PYMqgcmsnPijdWRpL/yjUYYdCjuX2F0omUUfQyrdVpVDy4+D6EXUvR2HkrnwKe18nE32XD10ciSSY42hF7XNIE56aqWLOHNX1IBGTIuK222MxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vdq0sfvdZQvwtkc9zPZeUijbgZXubiWRlIgEczIcQCM=; b=gzoSfLEYTHKAifpPllR5OXv1hlED6AnFOZcW4dI5tA+Fg6tAjspfPVvHn+MpK/SBvpHd/7cYl2/qHjG+LZqP1zDC92KiAR8ChwyFnrQ0oHmzBug5Rf7GB9B/1WOcZ1RI+de4ZjYHWRflqIRy7LCZYL+2vmTXbQOvFQwfc/pOIccIFinPmbHplvtuSu7Q186TqxuQ38emRVGt2cwCJEnLz34mkxszdaTlsf2THl3XGQtdsV3jk5Fbmi8TrFi2nF9YxXeT8q+J49FGOiDUGDzbOGIdUy6vDIkjMZ/XtYed95VdScnYJE6uE9AS6dbLOHfFBfYFZk+B7sOxQycgMPs4zA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vdq0sfvdZQvwtkc9zPZeUijbgZXubiWRlIgEczIcQCM=; b=sJJDPQOBedwobduiNPDfQFUa7Q0QVjt96X55OaBX/wuoygrEXzbVhEqyoqgtQIRP1w9UUJMABHP+XNF5GVEajXCAJXS9GeF/rJs3xsmi71Frzxi/e0D5wztJ71mez+3FhpncIM3zFlhCRF3xfYgdyUH4xdzeKUsWc8dd3yagRvY= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) by SN6PR10MB3088.namprd10.prod.outlook.com (2603:10b6:805:d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 22:45:05 +0000 Received: from SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44]) by SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44%5]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 22:45:05 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 6/7 v7] nSVM: Define an exit code to reflect consistency check failure Date: Mon, 12 Apr 2021 17:56:10 -0400 Message-Id: <20210412215611.110095-7-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210412215611.110095-1-krish.sadhukhan@oracle.com> References: <20210412215611.110095-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) To SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.201.29) by BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 22:45:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3eb1c28b-3265-4f17-0dfc-08d8fe049da7 X-MS-TrafficTypeDiagnostic: SN6PR10MB3088: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZI4F9mIwFUXybm4R6XlPjpm0xyze1oKSa2pGs4MLYKwZGLkPBtcFj609KFVscrH+RyJZIWYf//MagA4yF3o4+fr3QnfgfAqMcBxew6B2ppINxFqS6QTm0W3bxG2ItN9ZgQSx3yhywM4IWTR6lnNymQaVpiwifpR1MluOwcx5xS+h0uVHJkh9mff12d3vlsvIHepEdEHGLgTtRacVwcZKNupAbY+UApOhIGVn6BU71d5ml4npbJPEz0031m7aOt70ydAlm+M4HO4gWXly7OGUn0Zv7wY9Cje3XuQS1V3teK6oDFH1OM+//XTJ5Jr7VPyEPWla136uQeCNO7/zkYZTVmsRBlHU6+ut90OmtGPge2mQTuEKT9eqvTtsbP+mxhVbh+gCQNMPBdpYm9wiX0ZPZfV7cJydGH1t6vk08USsU7QWF6SCFzi4s0q8UAmxO5ItSNosJXZcyA5KkIG4CeznMEy5MW5gBF1FuX2rmdYLBXPMmYDA6/MrYunt0Hl/LGyND9lOnmVqVUsvK9RjEq80Ua3t2mSqdzkLbo7c8CDfsLj9i6BtLszJ9D/7yY0EAJ1rc+iAsdWeGDCXSMseGVThaSgXWJee2n9prbKnowclvWxTUHgZrK57M4j4Y3fyJ8OqhprIApQIYPf0dd4urqAB/A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3021.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39860400002)(396003)(4744005)(83380400001)(86362001)(2906002)(956004)(316002)(1076003)(6666004)(2616005)(478600001)(4326008)(8676002)(7696005)(36756003)(6486002)(52116002)(26005)(5660300002)(186003)(16526019)(44832011)(66946007)(66556008)(38100700002)(6916009)(38350700002)(8936002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 33hy0d6Hdo10NPSFBCNKGS9GUuG678++N+emFzgfTCFjMSfNzUVsV5Jcb2mP1qHbNQJAzC4aD8doXQAxNzUjk3meQvsVRojHrRiYuIwU/TfY75WM2gl1OhLT1sb9E2I1rQbNEspIw1bJCH9BfolhL4NdUQXIp9L3ZsSLCbCr0gUATSq0+3YtBnpkOPL6ZR5gHegM3RNTm4j7b/J7znn9WuHzFk+C0B4yza1glqp/Y5ImAkPvEJxvA83/sYQAXONrlIin/Jmhwu/aysjtA5bivJ37d+je/QVZxpKY8CX0PUyvGiB6rFWZ1jqQ+OtxvGF7K1DWnpgUsz/MfvuFsNpg1O5n+XOaGM9nCDsXGN8WZcJj/Ys8gVzixSfhgd/ynNSspGp+4m6dBjtR/wzSQLHp+rd/mcXgAyzFPCXAp4LTkCYhGkMtTROwwN8dZfSS/3+TRTu8afQSOMmsjNTLmg2HQBncxsLXLrcDhVE8p2VbPvAB5D004w0Cf6osG+LVBdCPoepTXPO3V/p6IJskS0PX4Vy2/EfE3UwOjcngKmdE/eMeLHTeVQQrARxFAqbxn82VA1muvQ3U40VP1aONrsT4/qjTEj/RLv01fNSJtcIBUBWEh8eQmCMTiPGsDSgtviH36vH18YBoR8LM7Rom1z/ZP0GI7Q3+IYJvx+c+7pBftIT0+HxtNK1cBat4SvYyuxHg/48vRzIo1w8t36ISHtnwZ+Wn2TxIM4W8tGNGLFSIfzKZqS+OBFubIrTSBvdClI77a1yWZZXiRoEtz11pPh4MlaBTOo846AwqnNPLKLDt91PYeyz8yFsWbi6ravItYqaRLs31NtbYtL1G5x9649uf8Boti3oII2/aUngQLXiDEkUIlDl9WazZK8yZLbhmTYItpnP6ZhxvfVVAiv1izZF5KDKh1MFij3XfMwXfdNHdW78BHfaw2hLhfKttF8mj4N/2KjrrG73FLdPNN1bPBTMbSBie2C6wdovWRewgIfvJzKyZ3vIm8BQocctjQcq4iJgN/TH1lLOG6JgTEA62ZOOa6To3DARSOYVF11ju5FCzLqpGGFVqBQBhGCuy42vJ/z/Ke69j0i2eX0e3IM4W4DLtWzLcx39bL5lQrcj1KMWwEPH8hhCcQhou1SVA1+7J9jp8JuAL+m2WWEhZ0qslMFn8O08p0GkgNnXJQFRZ5nyK+uiDr1DETIaexh1gA2cl9+/w30V5G65MxgxIYEXU5rWdxYLq97knrAI20fNew3Tw78Elx0LT2AAbHsRVj9hZITwgVyj1r5kXJ8b7xZ6NVAvSWnwTYfhdCWBdfEedA5XT5ECGx+NXElNSsVHm5GYgVD+P X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3eb1c28b-3265-4f17-0dfc-08d8fe049da7 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 22:45:05.3349 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ezJhbWK2VyXIAWTl36l1YJoXVOB/dx9h6sUPJ303GX8O0+d0UMD84mzxK5W3SFEn7kd8iMVRlIcCqzL5eOIr2AWcQmihl58gXovxHbGhyz8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3088 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 X-Proofpoint-GUID: tcv92qh5512y8ilVF1zc1cd8L5X-O0W7 X-Proofpoint-ORIG-GUID: tcv92qh5512y8ilVF1zc1cd8L5X-O0W7 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Define an exit code that reflects failures in consistency checking during VMRUN. KVM sets bit 63 in EXIT CODE when it detects invalid guest state during VMRUN consistency checking. Signed-off-by: Krish Sadhukhan --- x86/svm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/x86/svm.h b/x86/svm.h index a0863b8..48a07e7 100644 --- a/x86/svm.h +++ b/x86/svm.h @@ -321,6 +321,7 @@ struct __attribute__ ((__packed__)) vmcb { #define SVM_EXIT_NPF 0x400 #define SVM_EXIT_ERR -1 +#define SVM_CONSISTENCY_ERR 1 << 31 #define SVM_CR0_SELECTIVE_MASK (X86_CR0_TS | X86_CR0_MP) From patchwork Mon Apr 12 21:56:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12198975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29858C433B4 for ; Mon, 12 Apr 2021 22:45:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 034C361246 for ; Mon, 12 Apr 2021 22:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343865AbhDLWpi (ORCPT ); Mon, 12 Apr 2021 18:45:38 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51658 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343843AbhDLWpa (ORCPT ); Mon, 12 Apr 2021 18:45:30 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMdott178396; Mon, 12 Apr 2021 22:45:08 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=Hj91B3rP8y20bx09vOpC6s55LGxBookWTFt4g9Xgeqk=; b=j/U9GbJQM9MZxfQQojD+En0v8v9yXGrAGOldfw9XdndcgoLbeeCAC5E3qHBaaH/IMY0y srpLPAMpmm90NF49XQscxfR7iVyr0DFRO7IXknsjJok7WlnsfGqReF+EwkH6idnteffn O34JWXONccsCJO07DXheojffv0gGLF/i5nY0Kzdu76PeETbl8PEZfAJqFNyqJ6Q+RILG J5MrIP2nuW2RaTAfT2Zicy/4P3gnrNnuvN2bldqZbAd5Y+v5QWnyU+6MVPJHTmShC0xs DmF+UhIB0sYJlldmahuir6lBwjFvUkRwuRErGoV66g2lL+B6NU+S+KEldS94hfUa/L9X Eg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37u4nnd9nq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:08 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13CMfSgK009379; Mon, 12 Apr 2021 22:45:07 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3020.oracle.com with ESMTP id 37unsrhcj2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Apr 2021 22:45:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CsKWZkjhZuqSAj5mR5/vpm7qLPv7XBmp4HBGNHKp7a94k1Io/zDv0RsqSwFB1qvnwad5FAkROL2eHPpU/3VLIwaJTA8Tqbee+LtmqHbG3+jVa6p1FgSceuD0RTXC9BCvKYoqjdCzIhEEmk0y/oSXPAyg7bSH9pt3ybC1yVLr/VMjk3bOD9zYxIn86acEESPfFZlCJGCRB5m0wE5lmjp2s2YuQas8DPwctbnp3qnp3voX1hmKvXRTfVcQsXyg61SMNEeNwsYgPgmsWGtdV4XZ/Rw5BaD5z7EVlTWlPNBui/Igqv/aMEIthhnD3k/kqxWvND7dwiIjV2qQm4miWyKvQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hj91B3rP8y20bx09vOpC6s55LGxBookWTFt4g9Xgeqk=; b=LOwl6TkTnlRs1PHeyNoPjI4hUP3l66uSUo6WCzaeITYFVud1zTUDLR7Qk1T6QDM9yrJQUGfgnvAjJ777tM3DrsDfZoFyq/pbpQdOdhTOndRaCWdHnTiBZOWUXiq6g99YO2hF2vHWWx8z9cuG5/UUj7S2mSVqhe9ZuB2I5Ov9BNDh7QHvKWVz0HybkKNpvtcBkNnf8btK+JCKtvUI2XDDDCR0Tr/ounWG/MK89yC46Qfs54vI9v7DcJ3TxP8+2hcqwRwnZ2DoSVNntrXzWgPuC5ytvzVEiWzuNDH8GAsVklbkpBwWIs4hmVC+QkPbnSLnBP8V+VcrWgfRDriit463bA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hj91B3rP8y20bx09vOpC6s55LGxBookWTFt4g9Xgeqk=; b=eK5jmsHVsuf1QcOI4T78sMfKCoMLCqjkpR6BsqFdeP4vB6KG9WxXiKGHQ+w0wc/Cdr9mrsq6DJgov8/x5ef/mTz42dBOInTJA8p7fH245/GCVxPi0fAPOiBs1lyOVKsBdXHnGAmFQSM2U4riQukLP3f7DAVC0azhOomZBCc2rts= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) by SN6PR10MB3088.namprd10.prod.outlook.com (2603:10b6:805:d3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 22:45:06 +0000 Received: from SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44]) by SN6PR10MB3021.namprd10.prod.outlook.com ([fe80::5911:9489:e05c:2d44%5]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 22:45:06 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 7/7 v7] nSVM: Test addresses of MSR and IO permissions maps Date: Mon, 12 Apr 2021 17:56:11 -0400 Message-Id: <20210412215611.110095-8-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210412215611.110095-1-krish.sadhukhan@oracle.com> References: <20210412215611.110095-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) To SN6PR10MB3021.namprd10.prod.outlook.com (2603:10b6:805:cc::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.201.29) by BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 22:45:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f502784d-af41-4bdd-5d4f-08d8fe049e4c X-MS-TrafficTypeDiagnostic: SN6PR10MB3088: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d3Yd7YHaCKoDDWUn4yj9foaxUsBzBohjU29Df4h1H5+sOdZeFt53a/EBJ8jh15edwU/sQukaWdUH62whJutPGIGn/khKDF4E1rCjvOTIhvDVY16XnNthJBRtuE0mwIIg9JThQ6ojZnopKjJGIuJefhCULKy4/4ZmBzXJHM0SkZnaLuDpTsmafr8ljmHx5MiYUAJ/NBLVkmTCVZSEntdnzCP557Z4sqvoEX8EVnBf/shlM4AeKKRA2gtWjouBsJgn+z2u8ZrXuxCrjlAwnvqyQcwcNG6cLEMR+p2x3PX/L03RExvPQdRhe2hoWFVfa7DLwlqhRmkUYIzkLNjDeMe9DMSSF0uVlUVLjF0NfoZxXSnb/Tqg+SlxCg6BCKfLRONV27CPiXVaFJS+mZN7ZMFSKBNPUku5NrQlOQpGnzb0MQCjzTaEZivf1QGN6ifWlsJ3xhWGNSO68rqk6FtyAWU6DBNYphYWKouqLM/xUtnFWx7suXnL1V8+eY3JUgWOkhDpoCYlxaMwOO3u4Pq9uqYhnMwPb63gqr1buG1cBCadB1KwS09vVbx/yllM02Kdp1pYintraIy5YyuP1J/21qeDh83SPdn4Al0OJcZldsIhBSxm5BD5y25pCBGvKtYSvWB6a9amD2Wx+6cwY31Nyg5cNw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3021.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(366004)(376002)(39860400002)(396003)(83380400001)(86362001)(2906002)(956004)(316002)(1076003)(6666004)(2616005)(478600001)(4326008)(8676002)(7696005)(36756003)(6486002)(52116002)(26005)(5660300002)(186003)(16526019)(44832011)(66946007)(66556008)(38100700002)(6916009)(38350700002)(8936002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0xy30FNePtMUT0Up109CPN97ts0NvP3xWMJKPE0mGQzVVZrwiL/PX48W5Wh/ryd7QIAsqfoD8U7XR5233GuEw+HcJuSgZ6vQdqtpTQsqxER5Fa/dWFAtgyJo7e0oQBfY+MyhmrjadzLe7NODjdX4S9oRQqe+YKha6HZoankEiaNOk0Ee+s1CCf8Ujpr7GarlIsdcjK9Bcj04Ay2CynnW/Wyl2b/Koj0qk+0t6r9GHpDRLlpWZc5e3fkONuBKu+mLFW4RD3+0nHNXH0bEDHpv4zVRNVCJ+0Hzu8cltcJe3xq7mwUP8fiBjA3DPIz3AXdlOWWpYdsILFe5LYViLSYEU+Ycy4SP21HdPaNPJzlfkkdo8o24nigjt+Biik4esxJoshRdGWMbp3srGrgXtcER6dBVMybWUfqP1UWgOZQpzNxEKtWGKx028q5E0gA+SqpRpjnnmtXYn7wAyY24R4Ekeq70sn7geJPUpYn4cxTIvKCBGuc9wju4hdh6DM5Od4sc+KsGv8JjSASNt8cyTy37UBmmEkSDIabG3xdgRkHv9u3waXNo+7AXy4qUYgzJTTQF/JTAPoUR+2bnLazaWQv8HE6pKfMhZSdvXIdE/rNH7S0YPixMHatbrB+x0dsF3IZAeTsHp/i1vwDqtTysf4JBm4mPi9Jrnqz0TkDSRb7KrO2Q4lbWN9V4c4hsb/Tu4sLuyqRJF6pQUzJbLL9x3H2jrO0ufYdNP7wknKaO9811NPVY2nrPJ65L1nRikYeFpdQa6d2vpHA1SYpmSuKhzbA493b9tjIBYHtPkjYSJrDrOtGk+KRSk6t/z02wB6XTYW3Ktso9Fu2FrauGPZ6bCrlH/snul3UkR7P1o0ecsz33xD8qhcs52J1BQKqcFMkmQhCErTr7VWSQLttLZYZHqfO8QnnpitdjZqo1ES2lSe5VhkhwIk16tblutOIgMTS+HA60B+TtBvSnN65qxS8WtYkqjveOfMvPyTlvT/OsMp2DraxtPNcyjHe+9hqE7DZADFUJlzMkm5b+nDrbGI5muPx0hdSYtm/36emAKGd8j3vcZVysXe0JpagcHsUQ+DnkuHwrLxUbqD2o0inUq07LuB0F59vpKBjr/tmnklCDdZ31+3IVS9y8710p05OKuiAbVdwzsqDybxG4Ht3KzqGYwP6ZhX1kaxY9deYxYL62/LJriMQwLd+D9o9Fzl78HXJpRAPHa4RWuG2jJSRreZ7G+XssxuYupbwTkW7OUgex61uVjIvOEBsoFFgw3+venRQA7KRA8VRN0R8VsJ4wRev1H7y3PHr+5Q1hX6uqmwYDU2kWBrvOaHYPWQEoKcghPdmq3/Jd X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f502784d-af41-4bdd-5d4f-08d8fe049e4c X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 22:45:06.4163 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gSiyCKDpql5Jzh5rLhUhExrakdK71MPPXX59ierrrzSPG6gv0U/nk/uAmfyDcbrqZK/gfePA43M5mcgJGuQzO1ttlHLKli2CRL+WRaq5Luc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3088 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 X-Proofpoint-ORIG-GUID: 2SeKjnWVSMyXmIW0jL4W6SIp6zyvf9O9 X-Proofpoint-GUID: 2SeKjnWVSMyXmIW0jL4W6SIp6zyvf9O9 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9952 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104120146 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org According to section "Canonicalization and Consistency Checks" in APM vol 2, the following guest state is illegal: "The MSR or IOIO intercept tables extend to a physical address that is greater than or equal to the maximum supported physical address. The VMRUN instruction ignores the lower 12 bits of the address specified in the VMCB." Signed-off-by: Krish Sadhukhan --- x86/svm_tests.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/x86/svm_tests.c b/x86/svm_tests.c index 29a0b59..15be8f5 100644 --- a/x86/svm_tests.c +++ b/x86/svm_tests.c @@ -2304,15 +2304,91 @@ static void test_dr(void) vmcb->save.dr7 = dr_saved; } +#define TEST_BITMAP_ADDR(save_intercept, type, addr, exit_code, \ + consistency_fail, msg) { \ + u32 exit_code_hi; \ + vmcb->control.intercept = saved_intercept | 1ULL << type; \ + if (type == INTERCEPT_MSR_PROT) \ + vmcb->control.msrpm_base_pa = addr; \ + else \ + vmcb->control.iopm_base_pa = addr; \ + exit_code_hi = consistency_fail ? SVM_CONSISTENCY_ERR : 0; \ + report(svm_vmrun() == exit_code && \ + vmcb->control.exit_code_hi == exit_code_hi, \ + "Test %s address: %lx %x", msg, addr, vmcb->control.exit_code_hi);\ +} + +/* + * If the MSR or IOIO intercept table extends to a physical address that + * is greater than or equal to the maximum supported physical address, the + * guest state is illegal. + * + * The VMRUN instruction ignores the lower 12 bits of the address specified + * in the VMCB. + * + * MSRPM spans 2 contiguous 4KB pages while IOPM spans 2 contiguous 4KB + * pages + 1 byte. + * + * [APM vol 2] + * + * Note: Unallocated MSRPM addresses conforming to consistency checks, generate + * #NPF. + */ +static void test_msrpm_iopm_bitmap_addrs(void) +{ + u64 saved_intercept = vmcb->control.intercept; + u64 addr_beyond_limit = 1ull << cpuid_maxphyaddr(); + u64 addr = virt_to_phys(msr_bitmap) & (~((1ull << 12) - 1)); + + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_MSR_PROT, + addr_beyond_limit - 3 * PAGE_SIZE, SVM_EXIT_ERR, false, + "MSRPM"); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_MSR_PROT, + addr_beyond_limit - 2 * PAGE_SIZE, SVM_EXIT_ERR, false, + "MSRPM"); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_MSR_PROT, + addr_beyond_limit - 2 * PAGE_SIZE + 1, SVM_EXIT_ERR, + true, "MSRPM"); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_MSR_PROT, + addr_beyond_limit - PAGE_SIZE, SVM_EXIT_ERR, true, + "MSRPM"); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_MSR_PROT, addr, + SVM_EXIT_VMMCALL, false, "MSRPM"); + addr |= (1ull << 12) - 1; + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_MSR_PROT, addr, + SVM_EXIT_VMMCALL, false, "MSRPM"); + + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_IOIO_PROT, + addr_beyond_limit - 4 * PAGE_SIZE, SVM_EXIT_VMMCALL, + false, "IOPM"); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_IOIO_PROT, + addr_beyond_limit - 3 * PAGE_SIZE, SVM_EXIT_VMMCALL, + false, "IOPM"); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_IOIO_PROT, + addr_beyond_limit - 3 * PAGE_SIZE + 1, SVM_EXIT_ERR, + true, "IOPM"); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_IOIO_PROT, + addr_beyond_limit - PAGE_SIZE, SVM_EXIT_ERR, true, + "IOPM"); + addr = virt_to_phys(io_bitmap) & (~((1ull << 11) - 1)); + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_IOIO_PROT, addr, + SVM_EXIT_VMMCALL, false, "IOPM"); + addr |= (1ull << 12) - 1; + TEST_BITMAP_ADDR(saved_intercept, INTERCEPT_IOIO_PROT, addr, + SVM_EXIT_VMMCALL, false, "IOPM"); + + vmcb->control.intercept = saved_intercept; +} + static void svm_guest_state_test(void) { test_set_guest(basic_guest_main); - test_efer(); test_cr0(); test_cr3(); test_cr4(); test_dr(); + test_msrpm_iopm_bitmap_addrs(); }