From patchwork Wed Feb 3 00:40:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12063407 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 51375C433E6 for ; Wed, 3 Feb 2021 04:22:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14039614A7 for ; Wed, 3 Feb 2021 04:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbhBCEWe (ORCPT ); Tue, 2 Feb 2021 23:22:34 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:55650 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233189AbhBCEU7 (ORCPT ); Tue, 2 Feb 2021 23:20:59 -0500 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 1131OPTO196046; Wed, 3 Feb 2021 01:28:39 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=K/JC/iwkXinVeXeqOK1vvJXyi9JTK1hUBoMhLH2IIo0=; b=IOKTpro4IJ/REGZJeDwn0YGfT7xcSldKUIgaJLU5BT7P7WJkWu3sSvrni0h4ywTi9okP x9Rcub+eZkDSAxZ7iP1gG5/j1IG+X04Fk6sHEjBDwYGnfQVKtp9tjX4Iq04kKsD06xmi VsYUarx/saDlxcXL/hQV56BsazrIZKTDHV7XMMZTe/OsdCFS4VoEP1VQq3cOGBlNhDDa paCaqCNDnwZN1hg7ziI309BmXV3B9gqY6L228zqu6FnNud4BaZwGWeeiIvhmGCa1zw3s m9JCbuxvxUD3Tpx1exhejZy+K08q309SfL8YKAssWyLEePezOJPiGr9EvBOAJapSObjJ xA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 36dn4wkg5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131QYPk101028; Wed, 3 Feb 2021 01:28:39 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by userp3030.oracle.com with ESMTP id 36dhcxnvvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iRQK6sk5WGastNooi3i52iweq5RHLNv2mQAFC11sHuPls1idlBixY+rwWHm4i0xd7fkwuIFGQYOifmlY3jEgzmUaOCXtsApdliucAXCtmeYbBx4Q6D12AE20AX0XyAJrtCNQu8GlF9bhGpyf4df2T05PL2CHy2ZLLkJJ0AFPN9vPgzl6Cla9SKENxFdZ3Gh3WHPtne5BV4QvbW0ID2V95ph5JoIjERKyDB73pOewUgwso/OK+VLxG+D1CSIvulxJyG0LmMffqcTuuUo/Ahk3sMKzRiA2Z71ZppkSlRBfu2H2ctAmlpM/GgDmDHap82frnp/E3ZvmJafN1yoSbxGgdQ== 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=K/JC/iwkXinVeXeqOK1vvJXyi9JTK1hUBoMhLH2IIo0=; b=O7vecxrYztrtotmX0vCyZb1eUYBHTn4RPmSV+ynrg1NavmXv0tuCYkhuLuo1R5ReJCz9Khh2U8IoO0TV9dTBM7beK1YbRC09DNpUlRs3hDowx8ymhxNTPC2usAzroznhap4E2h/xx9EFROPOsIKPy4po67VqsIqI4WJyZSGkUMHOEuf2mpae/Dlrygkb41yN1BS/xBQLPk0E7aZYH/tcbyLOLwJn4PIejno21DnzDmDq1Qf0iwSraagqfaRSDh8+FJGMnJJFwshxpAFbiDKigKIUkBVF3YStCYTlYlN8nQmzSQxEDge19cUzprfcA0SHAHWeO2op+bY4yaLt6DSZpA== 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=K/JC/iwkXinVeXeqOK1vvJXyi9JTK1hUBoMhLH2IIo0=; b=z6ZQVNE8Thnbi6E6KsP1ilVs6xbYjj1eNME5WBAT518wM5lkquzGLnH34YICuc/8MKq6SvUZgrOY6sQuX7+wT1YKP3U/ZtZsU+3q+LBvJEt87693QvniGw4oAecDiSpQh9EubUHZv9mU6bVAvMedtTkKpPgVuJgvVKLsyIWKAO0= 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 DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) by DS7PR10MB4941.namprd10.prod.outlook.com (2603:10b6:5:38f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Wed, 3 Feb 2021 01:28:37 +0000 Received: from DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba]) by DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba%4]) with mapi id 15.20.3805.024; Wed, 3 Feb 2021 01:28:37 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 1/5 v3] KVM: SVM: Move IOPM_ALLOC_ORDER and MSRPM_ALLOC_ORDER #defines to svm.h Date: Tue, 2 Feb 2021 19:40:31 -0500 Message-Id: <20210203004035.101292-2-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210203004035.101292-1-krish.sadhukhan@oracle.com> References: <20210203004035.101292-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.200.29] X-ClientProxiedBy: SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) To DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.200.29) by SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.15 via Frontend Transport; Wed, 3 Feb 2021 01:28:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f61fe6e-167a-4127-bd08-08d8c7e3079b X-MS-TrafficTypeDiagnostic: DS7PR10MB4941: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T/XJCh2OrFxTBXbe/IOHKmbMpfbgPj+34/UTq9b2ZGX6X3WBrFfm4TZOY4bvbohNcnKLN9f0fVJKgLLvYAd+A7ZSnu4+QWqlmMN5sDKo5z+jHdb2jW7fwGMk2MjXDiGMqDwYedHnuGHA25SmP7ZD5JM1MKc5P+dwsoqlO3WlaFNugl/sJJiZUCI0304l6k0qaWFD+qnDfVkSGCAE1bqaM/SDOp7iNlA80bPStdrFi67Y5OiPdNL3eHgw4RtC437hSg99qIdotQWMi/nzttGpV18QAVnEN0MXaPS/uncQFFMyS2RHDu15N62CHU7Qpr861yyZN4SGJOxGkeoCtXM39VO3Kcf1xLcvBmnyA1Hj2EeIrvyEzEUBz5BylRGIOe4XFIo0ftCDTMgwXE6beIPDRpiLMeH8CglC2tgGSsvddclS6moQoQUzOoitKYCVhHBduYeeKuVPsjSRTe6TfUHBq5kFkRwMOdkjTm8sK4ZqNuW8fBHH/NLLTr/rsTLV7bF4MgCbvI9xBjZrB4IXsYezsA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB3019.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(366004)(376002)(346002)(39860400002)(396003)(316002)(36756003)(7696005)(6486002)(83380400001)(6666004)(2616005)(8936002)(1076003)(66946007)(2906002)(186003)(4326008)(5660300002)(86362001)(6916009)(66556008)(16526019)(44832011)(956004)(26005)(52116002)(66476007)(8676002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4qqYfF1HV0kb789o9P12YKscQmX/rl+woVKlnVonnHF1qLySnSDIhdNGPrrshyI5SXsf5W29ML34s5E/7N754kJfRYQQDCXtR9bq9K5/e++Gizun6ntvd6SpRSXVVtz8uGi6sTgeqlKU9/MfUwemty0vW4vU2o3L/ewE6hLPIwB++AF/mlgXAS8AlnfMwWeb7TdFLXBMrp5FCXbo+uQGNDnt22RNqWgtnR28XoecvgFCMpi43t36HFAXQGJz+6E8GyFPsZ9tYmtaHg4QuNL+8XnUYad+/pj8zUckzsLPPSWS5iOaaLlPIPMzsvs1fuJimokfaH5GFczzKX/9VKEb2I7QmFpn5vgkfQ2hGRHTRVjETYkJdcMpudqA8J0nkHKJ8QHyKVH8JmK578dDMzmC3jUXj+kEj6YbZTWXeUzSjvHkiVoARVnVqeBlVl8+wqYrAe36jwuYq40D9YddSKUdFI2lyyb1ZrPNwgZ9yTpq5FnsVTcYYdpkJFD/AHEItH0a/KrjtZLZGK9cYyIO6o0/PqfEye3Beyj1iljfJB+WqqfQqsydPQV/OjP8I9OsmgVY0Yi7CnWp4LPuYv93l7XLa1WD3ogjVsq4KKUNjm3H6M7It9ztupp9fvqCifBusNHu0PAkk3mZ/nbTO9P5o+VnmLoYgGwMVBTq2Onv8Y+/nqe461OvLi7AwRAcB+Rf7V1DgGvZb0KyJxPhUbuZxrMpKgLY2SYnWjpc3ozJMOtvlHE2SR8084rxC6rIZW4IP+lT7Uukb3dv3FoNcgX4mHhu65pmVMRd9RZThNi/iZVzr5RnDGMdMoMJQr3Hz20Q2klki00wyYRFvB02iNZ/sUc5VDeZR5fylLKRAZqwtLcxim/UE/wIBXKGw6NzB8D1psGYfKs5ppGmJNevcFw5UDcjcWabsNHV9HS5W0GNRh0nP7CPtOJngrMaCAAt0dfPW6fRDwg3oYta2MZZhKYSDNFVPE/kn6kdmhgTeqc+fBwlhjRMubkkpzjcKexur3fmYOu3D5qclbJ2+xKYtQgwRHSFGTgxMKJWQ3qtVA3XxKZLGlfSHBH5ftF9gxO1YDR28Qa7 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f61fe6e-167a-4127-bd08-08d8c7e3079b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3019.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:28:37.5393 (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: alZq75si0vrNAYefmY4LmC2QvI0ksiiyvvGXNDejCu1iScLEUT/USXkKhVc6dyhXp2UelGxyLZzkBbckE3wmm2zjx99lf/0mV/tOm4Mcs+Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4941 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org These #defines will be used by nested.c in the next patch. So move these to svm.h. Signed-off-by: Krish Sadhukhan --- arch/x86/kvm/svm/svm.c | 3 --- arch/x86/kvm/svm/svm.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index f923e14e87df..1641cb8ac5dd 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -55,9 +55,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 diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 0fe874ae5498..f529a259a03e 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -42,6 +42,9 @@ static const struct svm_host_save_msrs { }; #define NR_HOST_SAVE_USER_MSRS ARRAY_SIZE(host_save_user_msrs) +#define IOPM_ALLOC_ORDER 2 +#define MSRPM_ALLOC_ORDER 1 + #define MAX_DIRECT_ACCESS_MSRS 18 #define MSRPM_OFFSETS 16 extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly; From patchwork Wed Feb 3 00:40:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12063147 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 C0182C433E0 for ; Wed, 3 Feb 2021 01:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7294464F74 for ; Wed, 3 Feb 2021 01:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbhBCB30 (ORCPT ); Tue, 2 Feb 2021 20:29:26 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:46254 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbhBCB3Y (ORCPT ); Tue, 2 Feb 2021 20:29:24 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131Nb0H136145; Wed, 3 Feb 2021 01:28:40 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=WTznxVx8ksFCjA6Rxz97G43Gj9FIcS+R1neaENZFKRU=; b=jh2UvXNtaNsQhn9FP3KTWF2TUIg7NuiJLNVI4sC0dae9xAltnRE1ebtzYEoyz5f3cirH +dQWWOs0gFQ+u/hRl8YLrBis86PH65+kppCwtVw87k4Xwk//+42KsHm4LNkRnbSiIMgd +cChHwDZfkxN2z3R9CWlkNU/ElKXq1NN8wEg+6ucDQHd8AHNHgbv4r8OZYfB1HKIMONz TVK1qxTUiv+AUkqRPq8xWlf7KqJseHRmtAlfZpD/Tc+IQrOyneaXTV9O0erhO+w2njkD Pc6mx6ry7ghN79C2nsavhuhqjBwXDBlzwh3PyAwX7z7roGruhmYnyicAI4GblRxMDD4c Eg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 36cvyawtnm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131QYPl101028; Wed, 3 Feb 2021 01:28:39 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by userp3030.oracle.com with ESMTP id 36dhcxnvvt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c9wDruorWadUqqDTAnwSl0PN22AGYRrr6hh136WcTlJVBJ4GSsQAYRw7Lc+qP89GkGse77jDcsDAzpA6hu6hzKdKjB2zFtOiMf4ZgHZZi9QOKkrbfRM9IQPS0LXPRZkhDkChi1uVyAs3P98UHVy/Ion97hL3AnpN64T8zb6sNRYGZ9Qmk9xxmx0zWITSS5WlZYEhjLDL0vFfSKJPN54l4l233ZpEHtz9yN1Dzx7bvgkinNuDeUazMPuVFqBCCMsfyFk02HmLtFElv9zkTnP2iNkF4ZYku2RwowpAGF37H8R2Xz5Ra2ILupPAkqcR8X1cl6mQrq9l8msd9hVbCZOTrw== 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=WTznxVx8ksFCjA6Rxz97G43Gj9FIcS+R1neaENZFKRU=; b=NV3UIKcg3HoJoDYX8VowRCBy91lS2ByfjuwEogF0i3Bgn9VXLoAKT1JiBHFN5ND6/RgmTB/zcwT/Q/93FFsyJ3IeOva4OChiLt6vUU1w15p9mlE3v0DAzR/7Z1GXP4SCAc3qLSoNW4NSvkZXhNoebSMi4uXl/N8SFBiaye3+o0BBw31G3yA4fFrZIKvD/xvioSqCciyVEYVNkgcQOeFyKzlzPJQbEntziGkx0lwBHJkOl0DPX0UakWEDAzRn8EOh/p3amQja4IrrfAuHTaBFyvL/HNKaXjJpcTWT1YA3EUREx7tPiHTpaSZiRbSwh3sNAAiIeh0xflxFWTFxJ/ADnQ== 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=WTznxVx8ksFCjA6Rxz97G43Gj9FIcS+R1neaENZFKRU=; b=DA+j5q0yDtc1lhqg5FyB+xRsmPXcz8E3QWmqkzAPPebiD6zfBGqhkz5pvBrfBtPX800TCwG38yyVjgenWs3ChtrYqxS/SfRGn0PKC1bZ3pKQ4MnlsS4MMkdyDmiJ4bYkiFXHWJ8DZ8TTCMopVC3SCmet03R50DVLjxSJto60uIs= 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 DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) by DS7PR10MB4941.namprd10.prod.outlook.com (2603:10b6:5:38f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Wed, 3 Feb 2021 01:28:38 +0000 Received: from DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba]) by DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba%4]) with mapi id 15.20.3805.024; Wed, 3 Feb 2021 01:28:38 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 2/5 v3] nSVM: Check addresses of MSR and IO bitmap Date: Tue, 2 Feb 2021 19:40:32 -0500 Message-Id: <20210203004035.101292-3-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210203004035.101292-1-krish.sadhukhan@oracle.com> References: <20210203004035.101292-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.200.29] X-ClientProxiedBy: SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) To DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.200.29) by SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.15 via Frontend Transport; Wed, 3 Feb 2021 01:28:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d31b110f-102b-4b32-d1bb-08d8c7e30863 X-MS-TrafficTypeDiagnostic: DS7PR10MB4941: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xaMtfsIK7Sjrgi8MMkVV5q/WYxK64QI6DIGAzBOZIuexjd3sVTXu5CCHobSN+ASmyfcgPBIyeJMUAEPeAtGyGfem7CMF2CeyfaARDBd2kcX1WWDNNoxBxJIzWbA42uuGCAiIXXA7jd+4bUF7L5AcFcA6nK3VqJ0LsY/ys/ElobRtWKUnYWPCZ3bZoc8C5rswSaIslRu6t7MEowNAgBnZEUGSWnVTXAG2M7g+j7E17grA4lAEI1zKMs0XezU41xgOvt/ynVOzLz5web8SlE6NHfiqUo7xSMpGKqnc3jM/NUpA/na98cSwe0CD6j+5SKWzMiLq3w0H8rGTNRpe9zKuCbR9oSfUpz3UgQp00ZE8s102KGCGOEekbm1hHx64mFmQ74pVr5TeMmEgX6+qe5CR/K20R3jquXYpUD3LUDqAuqs0R346TB29L4t20DvSKiYHIYrikRcBZa4Xy2Vx+kZT9EDF/A/4U1rRYp/Elu+P5AEyRW9yTGU2IuwXOBkRAW+mdP9NiPlwi7BfJivgP5cqww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB3019.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(366004)(376002)(346002)(39860400002)(396003)(316002)(36756003)(7696005)(6486002)(83380400001)(6666004)(2616005)(8936002)(1076003)(66946007)(2906002)(186003)(4326008)(5660300002)(86362001)(6916009)(66556008)(16526019)(44832011)(956004)(26005)(52116002)(66476007)(8676002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: lS/ZdrRP8IDYm16eLEfEVLMR8jWF59C1z2SwjhjMdmLU5V5AKNKpNo4qxYKx2URq5g/QP7OT/wnWCAUwH6bgWTu5arhsW7sgpDNyouFav62OEzEcgKclyIiXL47GiFY7c/M+3RUbOef00Yj65+5V809Wwhsi6Act9V4IHyTwCwp6q8EmdrTx4rw4W7elfZrgOmIDJXZkExJ6IeK/pSqBg4cHuI/LHuzLl2UdHQ2c1emn7bbfprZss6r68RP1+tGaEu+OzrnYeu5gPbMo3ZdX5lYgsutOs+t55h++ZhgX+S+hWxYSoH8S+RALU6QcR7YMNns4CN/gsMuOs2F/HRD45qtbLhLuT4LjfCl3W7ldm6PmGN438telk0KSjOTbZ+BQ8KYTpDn7HG+2sFjN3F54nRSuu3JHkc9+d1GfTtezAXcJNkkzMUbQ9duO+AdZktppkhAiHuGneSY++syFLJS9ewaH4fz96lrbZmHJ3BPMqd020kBJyIwVQJCSzsNvBYwxTHebbA6cgLeqQhTi+BimYyeqrj2bpMhzssbL0i6H+ONIEypEnvHFgSbvtpQnF3tLu9JQzC+PYyCpn1vyxtxhoD19wDnWktL9n3wYKybHaVf4HI/F1B4L2tjChy4Zup1ev+0y0N7R5nI9DcbI0WyB/hB4buDM/OXp+ExrtsPjSEbqG6xoXWEikagIH3d9nfy5R6mLFoQRQezTUTS0STZHQaQXRbUhLRkXwkxhI3XDd4a9rgyDic4t/HRpTCxdXLoYlhg6Jbz4m89DmbO6QeJFTIcOdtZi/gQiM+y7IC/WZwVhzbDfnl7GAlgeRdj9oclherytTwdlHEnSRk0mlboG0Hac9bsxnNt4PfMbSP3IYvrEBCiNePRTgbmHJ+5I//TtERI+ealCd14BJLcWWuA9bWfra20HBtWfDrJk3FhE/SF1QaulvZS2G+ASqB23LG2hfkbmxVHIK4d/MpCz3uvtgo3bmRX0a6XYqkWlq/NccJk1C3o+8pfH48XLRGfjnq1Rs0nmpO78a6TV2MlOGrxxqjJ2QpxkJdt7pgl/7BMLOBBtMbugxJPUOdbUHEFiPWc8 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d31b110f-102b-4b32-d1bb-08d8c7e30863 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3019.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:28:38.8356 (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: 85x3a7pMhr2XpIFCD85iPKi1KMQOXchY5behlSfxClf+ofKjwY0BY0MnTVmMYBcZViz4zwljjJafK16kuwwl3SVy+ejXnC1yzTg7yp6/hf8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4941 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 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." Also check that these addresses are aligned on page boundary. Signed-off-by: Krish Sadhukhan --- arch/x86/kvm/svm/nested.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 7a605ad8254d..caf285e643db 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -214,7 +214,8 @@ static bool svm_get_nested_state_pages(struct kvm_vcpu *vcpu) return true; } -static bool nested_vmcb_check_controls(struct vmcb_control_area *control) +static bool nested_vmcb_check_controls(struct kvm_vcpu *vcpu, + struct vmcb_control_area *control) { if ((vmcb_is_intercept(control, INTERCEPT_VMRUN)) == 0) return false; @@ -226,10 +227,17 @@ static bool nested_vmcb_check_controls(struct vmcb_control_area *control) !npt_enabled) return false; + if (!page_address_valid(vcpu, control->msrpm_base_pa + + MSRPM_ALLOC_ORDER * PAGE_SIZE)) + return false; + if (!page_address_valid(vcpu, control->iopm_base_pa + + IOPM_ALLOC_ORDER * PAGE_SIZE)) + return false; + return true; } -static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12) +static bool nested_vmcb_checks(struct kvm_vcpu *vcpu, struct vmcb *vmcb12) { bool vmcb12_lma; @@ -258,10 +266,10 @@ static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12) (vmcb12->save.cr3 & MSR_CR3_LONG_MBZ_MASK)) return false; } - if (!kvm_is_valid_cr4(&svm->vcpu, vmcb12->save.cr4)) + if (!kvm_is_valid_cr4(vcpu, vmcb12->save.cr4)) return false; - return nested_vmcb_check_controls(&vmcb12->control); + return nested_vmcb_check_controls(vcpu, &vmcb12->control); } static void load_nested_vmcb_control(struct vcpu_svm *svm, @@ -488,7 +496,7 @@ int nested_svm_vmrun(struct vcpu_svm *svm) if (WARN_ON_ONCE(!svm->nested.initialized)) return -EINVAL; - if (!nested_vmcb_checks(svm, vmcb12)) { + if (!nested_vmcb_checks(&svm->vcpu, vmcb12)) { vmcb12->control.exit_code = SVM_EXIT_ERR; vmcb12->control.exit_code_hi = 0; vmcb12->control.exit_info_1 = 0; @@ -1176,7 +1184,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 Wed Feb 3 00:40:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12063247 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 4B3AAC433E0 for ; Wed, 3 Feb 2021 02:38:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 017A264E35 for ; Wed, 3 Feb 2021 02:38:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbhBCChz (ORCPT ); Tue, 2 Feb 2021 21:37:55 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:50298 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbhBCChp (ORCPT ); Tue, 2 Feb 2021 21:37:45 -0500 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 1131Ov8p015765; Wed, 3 Feb 2021 01:28:42 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=xZq/Z3g8M/JasXXwjsHckyjYGD1FpG7RMfGu+OE/pfo=; b=i4Lfg3MZHE3Er/ovpohd+LyyiL+3PmLW506X+7Jifr/omEsCd0fro4Ld0vGJZ4pjVG4U 7o6kyY3ImJmyePvvOBP9dpM9f9khymtWUfyuvH35trCUVzmbeKPyOLzNGuuqwe3ffgiZ yduHwHG8F2zL82xTpBi54bO93e8objhcMMdtNhu18YeSFDiCIqr6bBKMxUOgbmKaKpy2 uFQMIgv7LTBl71bFwG4+VeYcxCwaZUmc1arRk6visQOPewFYT/xYB/wCzc6yFmnov90u ghhlE8uoUfe4/Bbc+dhS3sVCCZ8vgoMWHfncEWxTjsEeKjPgz8ipDOEnbYtAbIgZGn0h hA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 36dn4wkg5v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:42 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131QYRb101012; Wed, 3 Feb 2021 01:28:42 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by userp3030.oracle.com with ESMTP id 36dhcxnvwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QLRwAuHZ9k2BfyPIgS2/L+s1N7GOXdw5vEEqqAj/sJZln/gljN0aIZ/gq5OgyTyR1aMOEEYD5zoG6fBwwN1k0sVs12eZXdYo/tINU5P9sGBqbMNU8icGgll7j7BHIKp7XL8QL7DNWqy8R2dWESlEHy7CRk6V1a/zW6WBRTFWc19OWKFd+r7mcF4xcQa2sBMCAg1cmTJYEykZg0QAOqMltLcj8bJ2mVxQuMSw8I48A5U6vmQwzghY3lC5oxdSRTpp20ZrByE+vXV8jdn/QZ1BxZ13O3liIeRNg13dp50rqSmD4U/lag97q2IvIpf5Hd0W9hWOQm7xplCCv+5uBcArUw== 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=xZq/Z3g8M/JasXXwjsHckyjYGD1FpG7RMfGu+OE/pfo=; b=EnjK3tQ6t9BvSEojBgKg9bAlTyelxoriJvAajdLPsxhb+7rTwUo0NjByYqAlG9+wPrbIa2b+Cz0t8gGLQ84CPsFAjsRYjEEw7zvIQvdjABuTrc++Frs1iYV/uMCC45+nmv+tu77Xrkg/aF6Pkc/1hWVDN6qO5dwO43EErANwjSnLT4X63hv7fefbyeOEeksyuw9erkb/YWde9cuBH5NliRSFbriVgc9w3d+VDdooOjSmp0EJzzzu/QYjviVDWeUnMH7xK7kOI2ES0bH/N/hkpUIByz7lfhjE8ye8bEinv7v9LQofjolTXyVKYn6XLraJnpJPm5CxjKabXCuLCAw8FQ== 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=xZq/Z3g8M/JasXXwjsHckyjYGD1FpG7RMfGu+OE/pfo=; b=mhO5H697qrf1ab8+NxgZFqSjY3BxeBKKSFzQH4AzurerlWVUt96IcQqp7XLdMk+CCfubYKKLPugLQJyf2Jxfj+Dant7VFu1v+8yZ3CHWnpGxgsEfjUy/jgEKzK0Nq2QDV1dUQJD2P8P2q3YpEUfzCciQ0QTJP1KU8H5wXOcfBdo= 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 DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) by DS7PR10MB4941.namprd10.prod.outlook.com (2603:10b6:5:38f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Wed, 3 Feb 2021 01:28:40 +0000 Received: from DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba]) by DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba%4]) with mapi id 15.20.3805.024; Wed, 3 Feb 2021 01:28:40 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 3/5 v3] KVM: nSVM: Cleanup in nested_svm_vmrun() Date: Tue, 2 Feb 2021 19:40:33 -0500 Message-Id: <20210203004035.101292-4-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210203004035.101292-1-krish.sadhukhan@oracle.com> References: <20210203004035.101292-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.200.29] X-ClientProxiedBy: SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) To DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.200.29) by SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.15 via Frontend Transport; Wed, 3 Feb 2021 01:28:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e0f8f72d-d4ec-4fc7-cc2a-08d8c7e3092e X-MS-TrafficTypeDiagnostic: DS7PR10MB4941: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6sJDB9dGSOCNZMHNBqY0SknsKa37rXV2jx4hwuTWdv5LSW3BTehY8ElnF46bacaltiLsUe5AHOJPVNPZCgtRxaB72NgmAmrW0srzAuUN4dYbHlG1TwVSd8gYEWB1ThmPmYlyNZVWjmPvjKRwVquWtWMk2X2gV4GwgnJzi08YIg4XjTpY7lTsn85QG1sgzBOlvd1mk4H8BUr+nz6sl7VcOptiMQwvynwXX4jkTo32LI0inAcPtJ0tLrNow9lNR3ggEnvvYQBNDubNmNy+VD8EBDveqVLh2BcmnMN7+PNi3bHhqF6cahBo+clAIfKcGYg1BO3VjNDrM+JfPZV7FBO4sFP4KaUntVE/IP+C/EoKtzvga9og5KMDln0J7Hl2nxyMnbQdB3UmD2JDgvxeV37qUZFL6P/HuACN7DYbGilZItsjxpTAQ2O2Jyw6UUt6oOCmwyIjOsQBe1b2roxCb2I6/dhly195ztA2ZvMBEZfOwWYf238ltFg6+W5qUInDzi4KHQ+A725DGBw09Xk3HY3UxQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB3019.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(366004)(376002)(346002)(39860400002)(396003)(316002)(36756003)(7696005)(6486002)(83380400001)(6666004)(2616005)(8936002)(1076003)(66946007)(2906002)(186003)(4326008)(5660300002)(86362001)(6916009)(66556008)(16526019)(44832011)(956004)(26005)(52116002)(66476007)(8676002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HfvMelyQBSebS6YJD1jjTxdmeYqU92n+OO44u8mI2xj7IOi952kZEo9WAVvTeJEVeBA3SRBXZ1WDgQnNMJjLLWPcSZnJmIuvGYwybzDvONs/jIf0/Rvx+chcs9lKB5lE3LqqkeWBceZjIUeSEwYOr0UqU3c6RfRa3H+cef4rOfYaBJtZAAS2hoHul7OYn2/LEaXxUV/t1TaK2/N6FBLB/UkRoxyDgPMej0MWWScGUI9ZUgHDC2ZYvIBqohAQKkGHzs8Od3zjTaXsWzj9urbn+Y3zRbSnv/PL1z6u08REz7931Qe2zsrdx5YRa+JSmaB58L9Oh39Ip8mAxDJ0XrTx81U+BHLP/uk2SzpADxoD45v7T/iQgY/jI0+/V1JCP1Pt47zwm1bkw9FrZNJTMapsaBZ8iRtvXJXIJZHekxW0isNjFGiJsvupVp9XnXozq0xKbhAkqsdVpb18r5BhpnSgdqVDIZINf5fckg9WPFYNngYZOCl1v/e93ofZ6PcD27+oLz1q0dJzia5SopSElr5eEHoRYP2GxFm9Okp5gCnvHOtYvWJoW2RAgrRB9UiTDa7B/PnTHATsf8YDfbPdI4x/ZUA0xQ/HPj6sQB8pp3hlHeWOIIlgfz1GRYv8rUkmL/KvO9souOrVBzLf1oJgkd4MhZXseEmX1RDRNRAvXUki7+hbPazGCkOw2ZjkMsq44/Td7hNGwgBCuewVBSgAbJzSYeRrloOerbBw3vyny190+22X3a8XxPlI5GQrRXvfI2rMqSygPUjJonDRIgHZpQpfWRCzINNJkv9l7KfDoB/7fDhFRzHHFeu1hkQcADzWA4zmZz3mwv5eaeFTHe1Gy3BX4/eYRxWQoui3qiy76FS9uan1XAZGF7OmHsccGCLF2Vjl20Sg50nluBjFHFlJqFfQ6SZlVgFHvsEzd3ub7weEYorZYb5YNSDxHh5SvnwwpkAooK1Lsmo1g1nM53Zq38cgAOqUK4keNQw4GWLSq3vKagNoPU5XBsTIfN1WCuNZhGQDEOgiUJOaoqyeG7rjfjv46wWQAVZKUOVddQN4hkpcbisgpVDIA/sBjrFaZtwWmD9b X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0f8f72d-d4ec-4fc7-cc2a-08d8c7e3092e X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3019.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:28:40.1808 (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: SRI4fHZECO0pO7jmemVPItfXQZzrZEfyJhNwFdkjCrIqhQ/f3woSZlU9T5y3lRl0kSq3lGdXr+U7j7S7fmxHRAixpNhQqskWr9rQVLdxum0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4941 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use local variables to derefence svm->vcpu and svm->vmcb as they make the code tidier. Suggested-by: Sean Christopherson Signed-off-by: Krish Sadhukhan --- arch/x86/kvm/svm/nested.c | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index caf285e643db..e9228fdac9b7 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -470,33 +470,34 @@ int nested_svm_vmrun(struct vcpu_svm *svm) { int ret; struct vmcb *vmcb12; + struct kvm_vcpu *vcpu = &svm->vcpu; struct vmcb *hsave = svm->nested.hsave; struct vmcb *vmcb = svm->vmcb; struct kvm_host_map map; u64 vmcb12_gpa; - if (is_smm(&svm->vcpu)) { - kvm_queue_exception(&svm->vcpu, UD_VECTOR); + if (is_smm(vcpu)) { + kvm_queue_exception(vcpu, UD_VECTOR); return 1; } - vmcb12_gpa = svm->vmcb->save.rax; - ret = kvm_vcpu_map(&svm->vcpu, gpa_to_gfn(vmcb12_gpa), &map); + vmcb12_gpa = vmcb->save.rax; + ret = kvm_vcpu_map(vcpu, gpa_to_gfn(vmcb12_gpa), &map); if (ret == -EINVAL) { - kvm_inject_gp(&svm->vcpu, 0); + kvm_inject_gp(vcpu, 0); return 1; } else if (ret) { - return kvm_skip_emulated_instruction(&svm->vcpu); + return kvm_skip_emulated_instruction(vcpu); } - ret = kvm_skip_emulated_instruction(&svm->vcpu); + ret = kvm_skip_emulated_instruction(vcpu); vmcb12 = map.hva; if (WARN_ON_ONCE(!svm->nested.initialized)) return -EINVAL; - if (!nested_vmcb_checks(&svm->vcpu, vmcb12)) { + if (!nested_vmcb_checks(vcpu, vmcb12)) { vmcb12->control.exit_code = SVM_EXIT_ERR; vmcb12->control.exit_code_hi = 0; vmcb12->control.exit_info_1 = 0; @@ -504,7 +505,7 @@ int nested_svm_vmrun(struct vcpu_svm *svm) goto out; } - trace_kvm_nested_vmrun(svm->vmcb->save.rip, vmcb12_gpa, + trace_kvm_nested_vmrun(vmcb->save.rip, vmcb12_gpa, vmcb12->save.rip, vmcb12->control.int_ctl, vmcb12->control.event_inj, @@ -518,8 +519,8 @@ int nested_svm_vmrun(struct vcpu_svm *svm) vmcb12->control.intercepts[INTERCEPT_WORD5]); /* Clear internal status */ - kvm_clear_exception_queue(&svm->vcpu); - kvm_clear_interrupt_queue(&svm->vcpu); + kvm_clear_exception_queue(vcpu); + kvm_clear_interrupt_queue(vcpu); /* * Save the old vmcb, so we don't need to pick what we save, but can @@ -531,17 +532,17 @@ int nested_svm_vmrun(struct vcpu_svm *svm) hsave->save.ds = vmcb->save.ds; hsave->save.gdtr = vmcb->save.gdtr; hsave->save.idtr = vmcb->save.idtr; - hsave->save.efer = svm->vcpu.arch.efer; - hsave->save.cr0 = kvm_read_cr0(&svm->vcpu); - hsave->save.cr4 = svm->vcpu.arch.cr4; - hsave->save.rflags = kvm_get_rflags(&svm->vcpu); - hsave->save.rip = kvm_rip_read(&svm->vcpu); + hsave->save.efer = vcpu->arch.efer; + hsave->save.cr0 = kvm_read_cr0(vcpu); + hsave->save.cr4 = vcpu->arch.cr4; + hsave->save.rflags = kvm_get_rflags(vcpu); + hsave->save.rip = kvm_rip_read(vcpu); hsave->save.rsp = vmcb->save.rsp; hsave->save.rax = vmcb->save.rax; if (npt_enabled) hsave->save.cr3 = vmcb->save.cr3; else - hsave->save.cr3 = kvm_read_cr3(&svm->vcpu); + hsave->save.cr3 = kvm_read_cr3(vcpu); copy_vmcb_control_area(&hsave->control, &vmcb->control); @@ -556,15 +557,15 @@ int nested_svm_vmrun(struct vcpu_svm *svm) out_exit_err: svm->nested.nested_run_pending = 0; - svm->vmcb->control.exit_code = SVM_EXIT_ERR; - svm->vmcb->control.exit_code_hi = 0; - svm->vmcb->control.exit_info_1 = 0; - svm->vmcb->control.exit_info_2 = 0; + vmcb->control.exit_code = SVM_EXIT_ERR; + vmcb->control.exit_code_hi = 0; + vmcb->control.exit_info_1 = 0; + vmcb->control.exit_info_2 = 0; nested_svm_vmexit(svm); out: - kvm_vcpu_unmap(&svm->vcpu, &map, true); + kvm_vcpu_unmap(vcpu, &map, true); return ret; } From patchwork Wed Feb 3 00:40:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12063151 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 36128C433E0 for ; Wed, 3 Feb 2021 01:31:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D303064E22 for ; Wed, 3 Feb 2021 01:31:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229883AbhBCBb3 (ORCPT ); Tue, 2 Feb 2021 20:31:29 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:47730 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbhBCBb2 (ORCPT ); Tue, 2 Feb 2021 20:31:28 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131NxN4153271; Wed, 3 Feb 2021 01:30:43 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=PsWu26ET1Aroe/GiEox5JHJTetUd/Z+jgu1B15egZvs=; b=JofT+gQ2T8IDBMHlQNXOhttCwPCS6W7AvowuJgFSrNR5vvVQz5AA8pBvJLheDFwxAns3 lwWJNvJqb/fEzn/oCgKL5gc7N/Vs+dYC//IfA8utvWb52eRCmRNOOWScr9ampgzv6BcN lUsLKeKiMtu1P+vhrXrdI8LbmwY4AN37QR3N6aPwhwl/jI5ydIxT9JtbTPeK6BRk/fAW kRiwXDbYlXk9sxrdZdtLz4sz6XUn3slPjQ9DvCBemyYuURvo2au6zjza44itZpV3yn8C 3f/exU/DATT2S2Srz1lSjXj+cWiDzZFz7C5XEHVw1YagFi4GB4Z6l+4ygmlH7ABfklBE Pg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 36cvyawts1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:30:43 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131QYRc101012; Wed, 3 Feb 2021 01:28:42 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by userp3030.oracle.com with ESMTP id 36dhcxnvwk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JaZTEQFC4TjFP1lLClHnpdA/Euu3LtdkTJeuWonxiKuC66W/S64+UvvlSRfdMBiprrgYAv6aUb1Ujp2Jpv2bgk8gfiF0/cgNh+zaaXeOeUAjYz78uNeFHUTDPUv4Ehe9hD/Vgkw9IyuNJKxFIsbGivnp9kEJ8HXLhKjljWSRNXpuwgkX5BaTWzfkXly+QalNnSgLKNKVunUXgLgu1s0L/U7tNNnsBP+Fm8yb+5ITD0VUEVcridugWOVjvvN9zZir6jmcSv2zALMA+FLbXc61jwmrQIgoIXwoqMq712HPvuOa6s24PgzzRaOwzgH0DjwVjcg1gfT+nNNl30N7t4X+OA== 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=PsWu26ET1Aroe/GiEox5JHJTetUd/Z+jgu1B15egZvs=; b=mH3hPZJTgOZRboEsx3OkWb1G+si7DM/WaPD9B2YW/LpiCjbUOxBlbD84G84bJcHS0PAh4w6kczq0ovykhS83ZHZmuFRrYDSHsgd0HzUQhABJpWVjuG7TxJsgof/GL0EaI+5XxauXr8A83G8SemUgepJ9uL+8FLt53WK3T7g+0fq5sZUmmA/u1hWfeYdD1RuND6MvpbZ7wd8JeOjH/9dLnoBblt5APhUn4ppqd5ZlpAJF75BSxHsehcgd1XRtncWQXnLzBJZSIAYKOYvxJ8WYD4tFyfvguxM+oM3lqlmWw6CiPKa/zpd1PO0mKirc05PwQwHbmNuNEsgqIM+L2Mq4WA== 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=PsWu26ET1Aroe/GiEox5JHJTetUd/Z+jgu1B15egZvs=; b=ITHxSH1iBbFOigi3//aAczgnN8T8jBG6e8KS0Hfbsyh6NP8K0e0KDRf2iPlGJUvkqY1A2QcLFkKNk21GBfX7fxuIw47yAdX0IwbItLvKlJljezvDgZq97bkwhVvImpBjmMecL/mSUJJTwsM0LjQ9cDEKcUA6j863iiHsnazhohQ= 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 DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) by DS7PR10MB4941.namprd10.prod.outlook.com (2603:10b6:5:38f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Wed, 3 Feb 2021 01:28:41 +0000 Received: from DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba]) by DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba%4]) with mapi id 15.20.3805.024; Wed, 3 Feb 2021 01:28:41 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 4/5 v3] Test: nSVM: Test MSR and IO bitmap address Date: Tue, 2 Feb 2021 19:40:34 -0500 Message-Id: <20210203004035.101292-5-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210203004035.101292-1-krish.sadhukhan@oracle.com> References: <20210203004035.101292-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.200.29] X-ClientProxiedBy: SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) To DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.200.29) by SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.15 via Frontend Transport; Wed, 3 Feb 2021 01:28:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f9e1d61-de50-4d9a-d604-08d8c7e30a15 X-MS-TrafficTypeDiagnostic: DS7PR10MB4941: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:635; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pjPfw+xNMwWI2qHmMm2n43bi8eAgjXY7SZZ9gQ8JbgwHftk+V5veKJaObwrjc2QwjXSVDVyAr/ew0HFFc8N8Am358GRbjKVEZbdvEt21BHaIWE30YxLTwxnzCUO1sc/P9VUkwACGKJJeFs2ikmekmieb3Iq5k34Gw6hJBXxPIVgQagpYMteG+rN8otGCiQRfpHmIkLP7oiev0Lzdeja7xLVTEDSVBKGUDc8tHcZCpmhifv0CjG3NLhV7SjN+Iyz9TCdMz3OM5N6HRqCvmt4hen3mre4dcirbplVAjCQaVU9WJ4RcxktGmDds1ib5K0BFR9F6wBXPYZ7aEx6LIBkzrbXjpHF5o7S8PeU8Vr87azIzzB71XHEYNe6XVIpubf1r4as/DlL3RAeI+cMfKh1jWuRx6sTYP7I+QXcQmUJT8r043iwJWZOgGP6kxt9VjIFRilp6E+Kgvov08wqenl/tBPfqs6Kf7qi5MARfDZu+EinUXB/NjSmX9D5OvR8d4uIBPzQH2gnHfJ2Y4gYtsrrQCA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB3019.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(366004)(376002)(346002)(39860400002)(396003)(316002)(36756003)(7696005)(6486002)(6666004)(2616005)(8936002)(1076003)(66946007)(2906002)(186003)(4326008)(5660300002)(86362001)(6916009)(66556008)(16526019)(44832011)(956004)(26005)(52116002)(66476007)(8676002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9g4oH41eEeb9JmI2xhF7X1+T+wLSs8Vm4EN4hA++7zB1H+LOTPha/JwA0DUaU4zKunJtBo8Hm+J07SOqXyMV0Nyh+qOvsB3ptu95oTf9NFowYQDArzIemdVf5pQusB8mptsyeawCGHiBcUJj1tBlwFcxHFT7dB1gr3wcHXFZ61W4JFGHKb/O82EuKd1d63BtjsIvpTf0Z38VgaLjJ6s/7+6H2WaHhb80T4WULxMEC5Mihbz1PHyNbmAIVANM6qJTgbJO6HV9sBZuzBAYEVaXTpfZo3tyTrp8GAXz4FtMe23xZRC4QTjvSz3+mpKYW9hPPKyY/kj3+QcJc4phxKI0OGo7UaNYPf8DMIpgFmpLbV5+3hcgU2qQK4zRYZ9usg9lBkotBwGbhp21uAWXc2Pj46qjQZnLmRHegSKGg/9LKXsqcNFDvb4rrO7OPeW6BAwDjag/Awh9GqhAmEq3IO8yZ3xjuagpFEbbc9JRFYqai8AiDQGKHD6n9h+Dzspc6Gqo3ue4NBsrcH94FZRsUuL60kyF8iS8IyF/nSdOgndmojLvm8MZqWlYx4dBtB7tL7P92SP4T9F1aEoWv+Vqf9bE2+nQsB7gNusx6ORacyLXjB3Ft1xkQ/jA1LxnDwdmZIpOzf/h8XS9If1OM2gXhB7MnJrY8uxJlVRpAQZDCbXI0jz2qfTwH8fnqZ69xzIBTwtJYkt/1+sGAW0cb5euXJS/kEFNMZzmN+QQSuduBlBJEI76sc5IAmW8xVh5IjwCchIlXgsoimX+VyGNugsjbMnrGGFLtw4KD8wup815DqTYjPafxkRmptFxQ2bHNf/CIBxx1vkG3sPZNZIYwedyeqRiTYBOxyM2Y4BLEmK1MqUoj1aNnChyB+8NwwTj/l7uEcoiNCWb/fOmGPCYwydhOrLYfDHNCxWAeKWglxXolajScb+Enx0e7A9tA+WzHbN1SLH5k4IpWUczKAL4/K8qoVU4E88Mf4PJg0Xd35bNV140VS7fPDCapOaCW7MiEhUBznBzwAz3FnH5S4SAmi6BFke9KsUPFAcYHfkGmSUq39qMdTQQ6lk7LfwhWUrWG6tSM7dW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f9e1d61-de50-4d9a-d604-08d8c7e30a15 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3019.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:28:41.5820 (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: bTH+WndcDDjmaW3WQQyuCqExjg7sf3KJ/1tZWiVtFxHGr+PiXGyxQBeqwEqgHyw6jlcxSF7Z1ywlDGygcUbrxOnQWyN5rjtyOaQT6+GrD1Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4941 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 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." Also test that these addresses are aligned on page boundary. Signed-off-by: Krish Sadhukhan --- x86/svm_tests.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/x86/svm_tests.c b/x86/svm_tests.c index dc86efd..929a3e1 100644 --- a/x86/svm_tests.c +++ b/x86/svm_tests.c @@ -2304,6 +2304,43 @@ static void test_dr(void) vmcb->save.dr7 = dr_saved; } +extern u8 msr_bitmap_area[]; +extern u8 io_bitmap_area[]; + +#define TEST_BITMAP_ADDR(prot_type, bitmap_addr, msg) { \ + vmcb->control.intercept = 1ULL << prot_type; \ + addr_unalign = virt_to_phys(bitmap_addr); \ + if (prot_type == INTERCEPT_MSR_PROT) \ + vmcb->control.msrpm_base_pa = addr_unalign; \ + else \ + vmcb->control.iopm_base_pa = addr_unalign; \ + report(svm_vmrun() == SVM_EXIT_ERR, "Test %s address: %lx", msg,\ + addr_unalign); \ + vmcb->control.msrpm_base_pa = addr_spill_beyond_ram; \ + report(svm_vmrun() == SVM_EXIT_ERR, "Test %s address: %lx", msg,\ + addr_spill_beyond_ram); \ +} \ + +/* + * 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. + * + * [ APM vol 2] + */ +static void test_msrpm_iopm_bitmap_addrs(void) +{ + u64 addr_unalign; + u64 addr_spill_beyond_ram = + (u64)(((u64)1 << cpuid_maxphyaddr()) - 4096); + + /* MSR bitmap address */ + TEST_BITMAP_ADDR(INTERCEPT_MSR_PROT, msr_bitmap_area, "MSRPM"); + + /* MSR bitmap address */ + TEST_BITMAP_ADDR(INTERCEPT_IOIO_PROT, io_bitmap_area, "IOPM"); +} + static void svm_guest_state_test(void) { test_set_guest(basic_guest_main); @@ -2313,6 +2350,7 @@ static void svm_guest_state_test(void) test_cr3(); test_cr4(); test_dr(); + test_msrpm_iopm_bitmap_addrs(); } struct svm_test svm_tests[] = { From patchwork Wed Feb 3 00:40:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12063149 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 1893CC433E0 for ; Wed, 3 Feb 2021 01:29:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C685564F72 for ; Wed, 3 Feb 2021 01:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbhBCB3e (ORCPT ); Tue, 2 Feb 2021 20:29:34 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:44966 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbhBCB3a (ORCPT ); Tue, 2 Feb 2021 20:29:30 -0500 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 1131OupJ149816; Wed, 3 Feb 2021 01:28:45 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=FCHR/kvHlyKbKvUjMwXY42SxTz0rqXup5nfnNHN3YTM=; b=EfltPI2s+3xRAs77ZI2xrGajo24lLXWUO37Fmlhffg6RFvZtL8WeFctc7qxrS1zQuuvy vFELBmd/xlBmzaD/f87cyW6sJZ4a4zt1na10NJ++KJrSHc4TDheB/io8MME4QWyXkhdf TdlZkhQOcjv2elc7IJBbSS10LEbCIfcbXsPD3OdCEGyFCvSWr5CWNJLeZrTBXjtiLjFN lsqkMgkeH4rg2GB9QS/9mS77L79MD3xf1FRwmmIcNarAv7Vsd0fprDd6GH3+kHjmlwPy 3n71CPrvxRmBMEa4fFXxJ2Y1dJ/cGxtqWFOuaK+DZHOOdCdRAhUAys4EyqBkfcTcaoea xQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 36cydkwkrw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:45 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131QYoG100957; Wed, 3 Feb 2021 01:28:44 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by userp3030.oracle.com with ESMTP id 36dhcxnvx7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:28:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V+oYAMwt+iEcgWsN/JP0Jtlf4KPkWKbrR/+wOmZyq1GDPbVlZvcqzwc5YOD+ux/Gn7HUU6lVwtdC0kN7sBXR28KbcL57zWbZmtyky6r93vlhjynIXMEZ7BBpufUCvqttWStfdD8wsHdqmQNIouH4OPBy5LMRb83HqT3b03kKamXlktcP9ujLH71m7ghrNaLfYUDNGgb9A5MgzZHcMunh/VWMELlBSzwX5EhZpX/mRT08uMjF1v6COAW6rehsP4qlkjYJKLsDh5syVhFclvCqGHqJczFPUyb8onmk3hSoZNcRjxoEXGHXuKUIbGzRczuwqQNeq+VxTdS3RGlUSB3gpA== 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=FCHR/kvHlyKbKvUjMwXY42SxTz0rqXup5nfnNHN3YTM=; b=RLpXINKU7yUHv5x3UJlUUYLV0pDRVvMOH/hEekvuVbd7lsQfU2sXO2+wQ/FYpbo6xbn5Wp0nU0gsQ7bOT1Y1INAR1qIQwfqOGgrxqNpH+cIj+ATyxAuNGb4ZvpQYqFmi782lRyx+KKEfaWaI/rm62Z7nFEWbp8Bq0lWaKI2b3v75x6ci2KYik9PfHYz8OUwXhJUTHjjJUTR1WpdhKTZ5xUZBh4DdF+vQL9tqC5UGJ7xgimBlQGQzQ4N3lxy/rjUA9JjvO8oUI0HREnkrZ3Bb2nZ8myeBxdV3PcHys6z14N81JzePp2WPl68A4M0IZ7l6yCIUH5/qlBXmZfCAZGYKsw== 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=FCHR/kvHlyKbKvUjMwXY42SxTz0rqXup5nfnNHN3YTM=; b=mE6+5lbQ4MbVrQS6S6+RIstrutPzlci3XDSgYwGnsm7UWJLbj72gLT2y4fF1U8QWscGXJ3bhsT4vA6JYjByMUSrCz6ohmyo4miZUmYiKq43LmLm4AbTzvhkgC9M7qzt7LDUrTazblGxKIcrYmbGth3KEtyPvf6g2MEaptXzfjtM= 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 DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) by DS7PR10MB4941.namprd10.prod.outlook.com (2603:10b6:5:38f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Wed, 3 Feb 2021 01:28:43 +0000 Received: from DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba]) by DM6PR10MB3019.namprd10.prod.outlook.com ([fe80::29f2:ddd5:36ac:dbba%4]) with mapi id 15.20.3805.024; Wed, 3 Feb 2021 01:28:43 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 5/5 v3] Test: SVM: Use ALIGN macro when aligning 'io_bitmap_area' Date: Tue, 2 Feb 2021 19:40:35 -0500 Message-Id: <20210203004035.101292-6-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210203004035.101292-1-krish.sadhukhan@oracle.com> References: <20210203004035.101292-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.200.29] X-ClientProxiedBy: SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) To DM6PR10MB3019.namprd10.prod.outlook.com (2603:10b6:5:6f::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ban25x6uut29.us.oracle.com (138.3.200.29) by SJ0PR05CA0073.namprd05.prod.outlook.com (2603:10b6:a03:332::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.15 via Frontend Transport; Wed, 3 Feb 2021 01:28:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6964ade2-63bc-499c-aa10-08d8c7e30ad7 X-MS-TrafficTypeDiagnostic: DS7PR10MB4941: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ukxZcoi+thZwMoZ2jay62JF0iTmfdDNpdLamwLKqsHhW5thSfN/0Km8yE1ANhsowBHtmOeU6jA1WcRej3bKAQMo1jzlok4qm8Il2iPjm3Jzr9E46d5GPBQ7XxmRrf884cHslVwChQsGvVWJn5FPHdjtltJHqooNqlAFrp8wmFiOeQbqbXDBeahaolcYIuDtbT+Vk3OgI3yDpqtuxABnBIhSFCfT0Zba99qHTg03aPVZXKGjWhwyM4n7UiPtTS6Bzm4Us3PdD5NpVszYURPNlaQWBTN1UcKPisoT0VWULgueISGNDna+jVKHCJ7TSC62Xqqo/M41D6yzSA2Z5GhbNNQK3tY9TMMbjwXoVgX1+jGMBDjyOTr0RE4zUFn8c8BOM1n8Vlo5CC6JCwsOOarWz9elpD8NegzG7f58/cquXHJmzAWYzEt6s43a58X5kffn2Cnkr281lwccOaT7c08JDcGdGgFEDaR57OW+wXmQF4h2hi6xIYugno05TUWdO4aT+HDWRYgj63V0eAe5HAZUfJA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB3019.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(366004)(376002)(346002)(39860400002)(396003)(316002)(36756003)(7696005)(6486002)(83380400001)(6666004)(2616005)(8936002)(1076003)(66946007)(2906002)(186003)(4326008)(5660300002)(4744005)(86362001)(6916009)(66556008)(16526019)(44832011)(956004)(26005)(52116002)(66476007)(8676002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: clk0otcLCgZgcdFeQA95ihje1q5Ax+iERmCU+xYKsBmbLHItXUas7QI9eP8xFctBc3RYGa/3/KVGdmQatbtB4HnvPFq1ccV4eSnKMjzAaQO4MwBSU0OLydefXT9t6ZUQnbSanMkfMw3+T0aZWZPyjqGJzxFIHneATaewE0nX5uH4eqOa1Scg/zJOS3N8HCK2eVoyEyLh3JX9mScvjov4FfU17CVNhG5XR4nMd+Xwjf4lRPYfYmsx9mQL79kdPIgESOlhbmz1ZbJI8bDTs0ul0jHWGKiQ93+8RnCtgkEDVZvfnpGyeEhr3IdzDprx8If4d8bzqIVOXr38C3BwfSkTnTR1eYSdoLWQ3xINLi83iUsFhEClO3G633P/wwz02ngJG97woEFWhHunJUq9x8LxImdcuGglivu8URC0oNf1Agpp4fipJAepuDxdFRom83YzzFWpF9wp4bAsxOhVDdgjzsNqBbPEVTT+2d50d7s6tXpM+LB14HGhjX0Hw19fUfiyK5XWp6QzfOLnl8PXLYKHFkKoLAWinjEUMqwpZ2yKPsi3DeQqJm4pI2jyIKMyGT1LE+fKBt1ypLPajX7MuRaLYG5U+vVJo8VuUNdJXRzwcNHPR+Q7KvHb+lZnU+J3xuffDmKysWMRsiNGvPO5Ffc5LQI0IXcujJLL8vY3vst/0+nmoq7DwVjPKNbbStr38roO6/yVxx571PxZtTHVD3iCku89LBf/qekt7SiA+HkSF1fFDaah6TMSHw1dky5WDqGK4mZYaaOo3jX6OcEkl1cBGM5daQddeVb++d4sMez8pv5MF/bopY7sFqKbriMubgoQkKZOpitIZtHrdJRdNNeVKMBZGhQ5WdNRVf3o1MElu/RtWJagDKuI1dT4oRJkdHKDJ9w1QX9wQh3InBwTSisuqP9NqXjYJL2gl6Bpz0u3CT9uY2lX3sVIE7CdU6V5dl5bUH3rGcoitnXdKyQO08hZbVZIuxFgZAyfGEH04E8CqtSWfAGglJNu0edpIf/EcZYNUHoch+uBt2vYmjas023lZ9phzHxqFfrqB59jssnCEIXRBqtNGhCW8ASaLgwf4fun X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6964ade2-63bc-499c-aa10-08d8c7e30ad7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3019.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:28:43.0262 (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: XD2nc7iUPgWjcAOkWN1SJQkPL+Eua1Y9af9sQ8SRF4aN/aFcrjARs5TKXNZsEEtWF+HkzC5TEtScjOdW4NRUHCaC/fuLzfd7cGWrgypnRls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4941 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Since the macro is available and we already use it for MSR bitmap table, use it for aligning IO bitmap table also. 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);