From patchwork Thu May 20 00:50: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: 12268735 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 3681EC43460 for ; Thu, 20 May 2021 01:39:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18049611AE for ; Thu, 20 May 2021 01:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230235AbhETBk5 (ORCPT ); Wed, 19 May 2021 21:40:57 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:41590 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhETBk4 (ORCPT ); Wed, 19 May 2021 21:40:56 -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 14K1bGhs155718; Thu, 20 May 2021 01:39:32 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=X11dOUZciKxmw/EEnQz1c/bn26jxWa9bmuE/WSNT9ls=; b=VzrFcmExobruUzmtEmmTm1saLMPxp9Wgl+kVt4onBNd/NleWpo3yE6NYY3EwJjYiaIxD qhqp350CDw+57GdCaySogJ/P/O2ZJn1jZOpuXD5nh5PbhWTDHRbRPg16A6tgjqU0lVH6 m1nkFgboNbtBEoCu9jG+2K2TZ2bE1+HLnuyDBEG5sbWdeZAfiIpT8z/RTqemweHSI3qL j6RHN5APwzWqItFXSWm/zGqLjK42kow1E/YX3HDK2LRaxl+FFG6VdwXULKJu7L5JTbkp PYoZjjYfbXybpmxT/1t4flCvuL3TYy74K5vRTrINOkpD8XTKp/FT1oZdMemeiLdAQh3S EA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38j5qrb92x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:31 +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 14K1a6nJ017253; Thu, 20 May 2021 01:39:31 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by aserp3020.oracle.com with ESMTP id 38meckwdm7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aJBEDRJW4Iok/QHIOTTOoeoaE79K6UkzT49B5zYWeXYNEcHsHz2DNdCTs0TgrODkFzRkigSwDTD/jRWpJURQzR2ljTaNVa3Yru2G7lsVYdP7EohHL/st6m7AYyl18KNSGlAP61PJUmZF3Ffz4iyXl6tXudLrBOyKt+JPXyMe+gxq9G3KFHyaFGiiAZCZZbo4P4LryzJlGjr9a/yU3qhzYaWdYyqiPJodDXIOz5wJovoxl+Uc9PeFSWn4eUktNvLBwEm0vNheRUDdsawa86YJJG6jeyd0iRPuUgK5Isj4uW5fgj7Ro9/KclpPmlGgDDOJPVDr9Hn9qWRNvVwaCJf55A== 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=X11dOUZciKxmw/EEnQz1c/bn26jxWa9bmuE/WSNT9ls=; b=lx++fJUdAlQ7gSZcoojiyKm+kQCF+F/34l+3FJ3K54q9mfyla9DM5IJ9potGMCQ2DKgIZ8hz+RpTHEUEj6X0OXG0+x0lR6ByefLoOh37NL4viNZz2rvjH89NnR0xnYByhkqdUCQ2Fhw7p2L3woLfZLABVW/ovLOj1fTDdsWvZVD9NAO5L0CJDXpDs8lW+WoJsYonnIV1FBsgjJALychNLIMUiVMcWDIfa68gWVgKfVYc0UALPqaXS0yJQr7fs1jpeSAc4tS8G8NKZDxPzqbe4Np3NxZ9l1Vcwjfx12r02fBKwIo8IYbjy1b9ODmz6HHs06u0oy8D65tYgz/gfMgpHA== 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=X11dOUZciKxmw/EEnQz1c/bn26jxWa9bmuE/WSNT9ls=; b=MCKaIoJRoNniKxJqV51tKj2QxvqOtnoZXRNzgQM5yKo6XM3TPgARJOfwwpbFW0ztIs/A1/sy/dpiSDYsEKRikbgcvCgEXBb3EfMd4387O/K4WoielhpYSeRu8bb5t2cTZqj3MjPz9pSIWaIp5VQa+NIAMkqUu+KN2ktGQFgTF5Y= 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 SN6PR10MB2943.namprd10.prod.outlook.com (2603:10b6:805:d4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Thu, 20 May 2021 01:39:28 +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.4129.033; Thu, 20 May 2021 01:39:28 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 1/4 v2] KVM: nVMX: Reset 'nested_run_pending' only in guest mode Date: Wed, 19 May 2021 20:50:09 -0400 Message-Id: <20210520005012.68377-2-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210520005012.68377-1-krish.sadhukhan@oracle.com> References: <20210520005012.68377-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) 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 SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.32 via Frontend Transport; Thu, 20 May 2021 01:39:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b925e15-b8fc-4193-a949-08d91b301b60 X-MS-TrafficTypeDiagnostic: SN6PR10MB2943: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7I5bbkW1KgABQMVlhrltQMddsGGhEhbGDGRNNl8U01M4qV3VNpD4JIkWi/yQ8oEV6upSvsVoHSmJpeNQ1NOmSr9de+uhjSU8z24VT6Y77b+vbVsP4eJjW27/HtmNRO7RLjOYJ/wg5dxOI0OI2IjULSLx3OLFIXJk9zQkXfGgcW7m1KM2Isxa10CW1mmIoBfdzhV+gUKiExEpEO0oEmTd9CDYY/ypkDMIaERp2oSRzmNbfVgKGlRvKtnZFGBEw40lRzIrRsRiOe/dvbSK1uCWiQEHYsvqZpnqdswHsbPChebv1Sl8td87Rii2zNRXpFVftRE7k+SdTObHhBdcl38qemNGDcKtGtjuLi6XmVcvxND2GYRRCal6IP1cNRKDmOuGFPzn/VV+0l3cCM4W8Z6W+pUqsBk0rljhFKAHskmPwvEeysrDbv9/+OILq4lt8rTLsvdExYTkP1LbsIguCE83+IUooYAVnGqD8Jj6phGN7kEPBjeKc2n6bNtZGwLSCUf9QCKBs5VPvHO75YeVcq3tL35fI0MV1gHIFIpAQWXCAdZM9m2ZbUL7DmUZ69kiF43er/WZCBx+I5ts04NngY7fE1y//WfwXRgLsxeU7lJ2H8VWV4umTRhgnFCa3PqBmWhzYGoI8ZiI7eqKKw1LRXiAXA== 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:(39860400002)(366004)(376002)(396003)(136003)(346002)(1076003)(6486002)(38350700002)(6666004)(86362001)(44832011)(38100700002)(478600001)(83380400001)(66946007)(316002)(186003)(8936002)(7696005)(6916009)(4744005)(956004)(2616005)(52116002)(5660300002)(4326008)(26005)(16526019)(66556008)(2906002)(8676002)(36756003)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: XOk6RvyJ8NPxb3plrP38lAokJIY5Xa94Ux/30O995ByI85HAjr7xxet1sVewnC4A6aft7ve3UgBCgvUcNWsnjjVATe0JBzpJts7Hssjs5B1ItlQdr425ykdQuPjzKyCR1eqgSj1iuEpU9w4552gM6H/4jWDfjtr51rst7AJsj7DvoBozQEgmXd13anlOewFY5WkXhowrlVdrAwZYjE9QZa9bmNYhwUkwClgNfW/0w3CxgacMxGhDMBUWBqCbWWaX37mWQx0VLmI+9MP6DaRayjp0SH+MN2hVggOKxVD2uyqPZYHq4ABkA7bSznYOXg8dOdfI0JaMv3unYr/Rl0CzbPzS6ZuXRUQ5e9DU66nhpQNAT43bfNdoZoPcTJM64Mox3XbUY6QWcLJR2h+RkOm4bcIpiGQf91rRjhjSfTOBCS0VLALcIt3DyOz8CJ40aiITUdmxwo0OXEwDC8hxCaziu5zRBqHQzGxiEKMQgsJ0mRqAth50BSijbHUYGIYyddgMjLZcwYUF36H+vM+6B6bOJ52lFklpfyVBecqlTx7c/ZO+I0Gmctb5fcrTDcP1pKUYdHfckDhD7tlmxkrCaftechmqUS/Wh5wFc7WMLFJvfQFXxkUNhs6/mX/Avd+P/59NZyPPOzFxhMrXD3/VUO/WzKtYqSINOhlfYfRjMMEftcy6bD2zmgyp+SC6ef6QwLcQd2PAByAB7VdM1SVx3TQOMtuLAD9EhVbVre/ceL1Hw8qx2Bc/ONO3bcrlyTV/ruwi4t9rj/O+NpUZ0Oe2Lxauy6qHRg9r9XE0XwkIF/PRW4+PhtrEPSS0AhL/2TokfMOKsVspzozRQtXiIVlawR+RDusQeEDwdPqOP/w2eQDd7jajZNuFSs+iE/3TLlhNLBPcRmQvAItHt/A0NPwKVSBWnOxPFT1NWKj0+soAhzSYXxx3CUwAewAsSJI/BDTQdqog/gzaIQHwG77c5LrdnQ/0KOsf/18ldaS1KxSNF6JQrygvTtgCMQahVwWE9zw6g+ByUNMo55n6PeJ7HD3yUlr2LktGAMjlYmjYyMsNnIWpbOZZRZmyxD1VfgHFVu0cMJWfvWpLLaT3Q2LnqBw+Z7EaA48b5TcgrqVzfYeTnlIoVx1RxcbzpXwOcpyvLO7Gca0ECYfAoHClDK83CvhOZhrD6PBIvVkkyZnEIJk2IhapHBtAID5MTWejbIImaNLCP30LbSx13yABoG8VF4MDx8zpJvcs1SIuYPvdg5dIO2xdwVOZVZM8xzqOGbyf3QIO50qxz9IEcfuq49Wwbfb2MHV+yY07s1BUlgB3/4ENR07skcHaL2WQWk3w01yVMmN5eAwd X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b925e15-b8fc-4193-a949-08d91b301b60 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 01:39:28.5403 (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: f5D4SQ3Xl1qXdVSlRsM1WIsP3gZrWK7SdK/Kcp7In9EY4MS0Z2+4ByFouagMt30uZzXUq+UNAuUK7lKKu9nHdLxrYvOK9+0C8E2kaGXwy74= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2943 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 X-Proofpoint-GUID: T5b7sJ8xW1yfG0qNKT3N9WZ6KusbuVgj X-Proofpoint-ORIG-GUID: T5b7sJ8xW1yfG0qNKT3N9WZ6KusbuVgj X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 adultscore=0 priorityscore=1501 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Currently, vmx_vcpu_run() resets 'nested_run_pending' irrespective of whether it is in guest mode. 'nested_run_pending' matters only to guest mode and hence reset it only in guest mode. Signed-off-by: Krish Sadhukhan --- arch/x86/kvm/vmx/vmx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index f2fd447eed45..af2be5930ba4 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6839,7 +6839,9 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) kvm_load_host_xsave_state(vcpu); - vmx->nested.nested_run_pending = 0; + if (is_guest_mode(vcpu)) + vmx->nested.nested_run_pending = 0; + vmx->idt_vectoring_info = 0; if (unlikely(vmx->fail)) { From patchwork Thu May 20 00:50: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: 12268733 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 A21E1C433B4 for ; Thu, 20 May 2021 01:39:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FC4060551 for ; Thu, 20 May 2021 01:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230197AbhETBk4 (ORCPT ); Wed, 19 May 2021 21:40:56 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45654 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbhETBkz (ORCPT ); Wed, 19 May 2021 21:40:55 -0400 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 14K1Z0pQ109307; Thu, 20 May 2021 01:39:32 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=zoa5ankHEh2OBCT0Q9bVTohB/rmrokHnOUJOHQqIuXk=; b=TCFn4yA7y7tL5xVO2D6DS2klSiCDVDofz/q9bI8faBXZEyuQ+nSbUmpUTvolkQqqkGzC Lgo/26YnE5o1nrsh+9U8lWxEcgD8JRZFNq9aU37ovmMyolquH45e35Se81VqnZ4DGZ8K /d8JI0W6+CIepP2uHLY3QafRv0+m2QeheU4Ffk+34T2z0Mf1YcVmbfc8/SijRcvf+r81 oeUAvX12er+xnsRJuehUbjmk+tVlBAHob8f+rOIc7AMlZS65CP27QzCDGUMFGPbhBQgo Q4hius4s9V4XMofCbMDn6RELqz3wJQGV8pYRSu60666+Ucyfd16bz7HOP9J/B0ajPsj6 UQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 38j3tbkb45-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:32 +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 14K1a6nL017253; Thu, 20 May 2021 01:39:31 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by aserp3020.oracle.com with ESMTP id 38meckwdm7-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RO6ZkG0AzNP0SILWtosO5Z1F3wsscMZvOkq8nwJ0syV4tJoJp5HA+Dnks8Zr5HgQnjoUyxTSy4IwYdzNHqoRqKxlm2u1t0NWhBZGQlGN/Mt9PEEjbAAP5TYJVzDyaQEO6hPzOnhuuRfEpLCuJL1rF1Ls1foEwuPMp7tebD769U3io0XQRJXcoqi90UYvm5PFqKhROIMEFCJlUGltzNqGzwPyEd+luZiz8JkoW3UloiO8+LOC6eSTXojaJDpt71nBAwpVviZYPbAWSPmWviWQxHnzMaAGL16JGTNrgS9s8JcgNC43p4n9Bj0ePa+B10pH/r/pV7AneMp5enLBgAGNXg== 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=zoa5ankHEh2OBCT0Q9bVTohB/rmrokHnOUJOHQqIuXk=; b=gQSCbK4dzHnborM05hU6fzr8EWNxLg9ApgxuoR/1vrdU6oHN1UFLI2SsTvRjESHsrRieYSTdJcJ0PSF/HcGr7NZiY3eDh5vZ/haSmmRGuDGXJKyRuhPETPA2eNvFxhqZIuxoyxRMobXD5I0ycqsDNR9zA30M6D2vFgocJdN/D+qXdLwYLxK/o/0ASbAj6xBcZvL+3aYSd1arb9ZSRNL5yjs5HJmsKRVrCpAeAo4AoqK2uqOXf9idIHmfS+eiYowvdqFDtmliA8gDOrpXbjRIN+16uW9tbtd/3CY7xDNBHZcYUtCX1SQalcMSChAoy/JUJ20PcGJwPU6E4kyYAkXlzQ== 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=zoa5ankHEh2OBCT0Q9bVTohB/rmrokHnOUJOHQqIuXk=; b=JgRlDMx9l+fnslkkf9svR/BA7XXUWsyfvm2JsXM7sP9KDQpBeQnSOCUvTn1tngicHo3fdPfnUAB/4KdxrrFD8cy51ib0l/C0MrJXNjob22Ufe3+kRcQwxnz2yschEoppM3T5slLjBNjbg12uCa7cDarJxQsWI94q3vN/998W7J8= 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 SN6PR10MB2943.namprd10.prod.outlook.com (2603:10b6:805:d4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Thu, 20 May 2021 01:39:29 +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.4129.033; Thu, 20 May 2021 01:39:29 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 2/4 v2] KVM: nVMX: nSVM: 'nested_run' should count guest-entry attempts that make it to guest code Date: Wed, 19 May 2021 20:50:10 -0400 Message-Id: <20210520005012.68377-3-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210520005012.68377-1-krish.sadhukhan@oracle.com> References: <20210520005012.68377-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) 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 SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.32 via Frontend Transport; Thu, 20 May 2021 01:39:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d2c4198-2728-452c-a806-08d91b301bec X-MS-TrafficTypeDiagnostic: SN6PR10MB2943: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hkvxj5/U2+CqdcSMdoDFaCDwSOAYoG9pev1ll2dgLkWbqPJBEgx7ZWD0UP/jLKF5J5EyZx1n/Hwfw65A9Xv9p2C/BUyFe/7kWKNsNV8A3WD5SSLDv+7ihP+GqMzAIydEYlVFs0218UBMNbI9ryBD8bXPOD9Wc/JagwbnVhN4e5Re8ZTR4bnTbSy4e3c5bo390hhie7Jpez2Cnh59iCxS+9Io87kExmJiF41I3aNJUane2wyG0BUIWp8yhiKnuyZQArRXNE1ly7VfuzPMTugPJya30ux6hFU/Grjitm5lAP1FTD/XPbffWZqHitL57WfCzhmHqRzRLU+x3Ows99oOOFYIaKAnZEik3KuhzfX6xjZLWMVNbwvuIbcCDVRJ67zWrOUpSpmrHMKVynWWVw2SRpluXMUaqzUTFW1JTC35RQoTPLm+1AU/6HXiu/R0Nb9jN8K2tUtWYEac5aouv2q8v676aMrBMXeiOzCWgyfMS/btsxTpaHZLvieuz9ewBQ2SXInvsyp1pG8q7Ro061Y4UnN+vQOINbNaWSvhdE1gHdj2e+6JHqRmvuH8fzqyOMTC1S6S1zCf3/QtpcMH6sVwLs1qMOQE+Kx+7J70zBHOiFmwVP/+mzmN9u28GCaYbIZEO9oxPeBhDmYaqPlxcQTQgg== 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:(39860400002)(366004)(376002)(396003)(136003)(346002)(1076003)(6486002)(38350700002)(6666004)(86362001)(44832011)(38100700002)(478600001)(83380400001)(66946007)(316002)(186003)(8936002)(7696005)(6916009)(956004)(2616005)(52116002)(5660300002)(4326008)(26005)(16526019)(66556008)(2906002)(8676002)(36756003)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: U6XPTAwxnzwGVvnpc8LJUtdrH0qx1jP766BQ1lfB9YLvWTVtQvFs2al5x6J/Lk2QLBaoMqjq4Ore8/PfLrJXVzOKxx/qaGhdT9/pnTMfuWxWInIX1qonV025bEIWvEL71RdP8qtaKajeHXJt9nitn8gI+vfuHxW4ktrXto3yvixbjsFbhwWL+NjrmrSub4uKpsfw7PZzHwqqOsv44XVwoquDwaOE6EOxq4uTGh/eNAdLvkQLt4bQqGq3M4fX5qpjinC/4MclocmKpK0evWfYIpSYIiMALcgHA8pc/iGbqPJYSbZIE494y/s/JbRvkYu54ZtSlR4ZbCyG+K6t7kHDly5jkorVvLTj3iukS5Csw2aHnrhaQ1odkafuAlIW1ZFHB6szRoATSKHC+1bfZGjP6vIXwbjVZ43kSnk3qh0a9Q9pgihjmsukwyqnRrEJdYmCFY2nh89iUzyyzY184jeETBSOSHpM8PlKZOFUyR34bN01NFQyheE/WgUdejxWhFXXMssNPkcHLhOdJUOeFv78OAigsJSK2y5Om8d7mO2Gx0TXC9PEmZXCWsM6a2Q9kHU2Hwjsq28FX5AA5PAMDKaC3UbsnQdEQe3Ks2fLjDjiEDh2xZTUjS+FSxrmGXmLCGPl5TKm/Dfaf9jlg53K1BEn7ADOBCtYgh/v2bqL3qMF6CEOqhMLOBfU86Cp7fxBBv4GzTFeCldFWFWvSWOvoEJ1jzoXifNuK3IC4fIOQLyBZK5xXZx4A475vt6Gcmi7PBblAazHwBDqz6/XHNJV/uKUhOwkkyPWYrw+0cd+oyUbpkQlqhAeClTGIdG2i0tTe7qk/1Gn8RVkIG4dbmQC7idBiD3oysczEJcWKq11d06QyVG21LmiAhGZc073cd60Xe2veQFyMD4RPY3PRV6gfeUJnrk2DvXmNwoAwBOLnuWjWR54QuS3APz1TB9ANLBgd6ab+WM8KsZA9jE4+0STuDNobpVR9cOCNOOFklP56XaMFerBb9zsXuY3jMCAKhwUVGiLnjZ0H0Os6suuduObqTlpiLI0XUL71NFZXLAVmhNM5lMsX4+DaM1STVYptdijjP7FK6aQ+IJnckF43INYiXeQ7pejf28/TQJXlCfrGZjh43l4UL9vVCAXBKjB3DxcfQM2ZhiT5IzLJ/FmBvti1ev2KfMU+GIgFvT5TjM+uyRGa4TiztG0YUlD5kKhTyDglx2EPD8vN/3/Lvv0tFMwn76Xw7W7v2fo492/kxC8MWUJrGbvW6l2lCag8RjMe3eySY+M/TLcNiyGPPARktUiBRWBWhUUOaAbMCEzybKfhYDweXor2vN1zr7CU/RlQllKzkPg X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d2c4198-2728-452c-a806-08d91b301bec X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 01:39:29.3508 (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: 52qEdj4Gr++hVLcurc4Q8m8gmCVaFWZDtEN7wZXn3shZ9NsGG9Zw3bXeD8Ue2ksqEtvnvlz0kjbKZIC6BVyiSRGgKKsex8Etxj5GMhW1ch4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2943 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 X-Proofpoint-ORIG-GUID: i6h1JnfWyo9zd_4RsOxRQ2ElxMD5TTpa X-Proofpoint-GUID: i6h1JnfWyo9zd_4RsOxRQ2ElxMD5TTpa X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 spamscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 adultscore=0 clxscore=1015 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Currently, the 'nested_run' statistic counts all guest-entry attempts, including those that fail during vmentry checks on Intel and during consistency checks on AMD. Convert this statistic to count only those guest-entries that make it past these state checks and make it to guest code. This will tell us the number of guest-entries that actually executed or tried to execute guest code. Also, rename this statistic to 'nested_runs' since it is a count. Signed-off-by: Krish Sadhukhan Suggested-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/svm/nested.c | 2 -- arch/x86/kvm/svm/svm.c | 7 +++++++ arch/x86/kvm/vmx/nested.c | 2 -- arch/x86/kvm/vmx/vmx.c | 11 ++++++++++- arch/x86/kvm/x86.c | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 55efbacfc244..cf8557b2b90f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1170,7 +1170,7 @@ struct kvm_vcpu_stat { u64 req_event; u64 halt_poll_success_ns; u64 halt_poll_fail_ns; - u64 nested_run; + u64 nested_runs; u64 directed_yield_attempted; u64 directed_yield_successful; }; diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 5e8d8443154e..34fc74b0d58a 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -596,8 +596,6 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) struct kvm_host_map map; u64 vmcb12_gpa; - ++vcpu->stat.nested_run; - if (is_smm(vcpu)) { kvm_queue_exception(vcpu, UD_VECTOR); return 1; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 4dd9b7856e5b..57c351640355 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3872,6 +3872,13 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu) svm->next_rip = 0; if (is_guest_mode(vcpu)) { nested_sync_control_from_vmcb02(svm); + + /* Track VMRUNs that have made past consistency checking */ + if (svm->nested.nested_run_pending && + svm->vmcb->control.exit_code != SVM_EXIT_ERR && + svm->vmcb->control.exit_code != SVM_EXIT_NPF) + ++vcpu->stat.nested_runs; + svm->nested.nested_run_pending = 0; } diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 6058a65a6ede..94f70c0af4a4 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -3454,8 +3454,6 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) u32 interrupt_shadow = vmx_get_interrupt_shadow(vcpu); enum nested_evmptrld_status evmptrld_status; - ++vcpu->stat.nested_run; - if (!nested_vmx_check_permission(vcpu)) return 1; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index af2be5930ba4..fa8df7ab2756 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6839,8 +6839,17 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) kvm_load_host_xsave_state(vcpu); - if (is_guest_mode(vcpu)) + if (is_guest_mode(vcpu)) { + /* + * Track VMLAUNCH/VMRESUME that have made past guest state + * checking. + */ + if (vmx->nested.nested_run_pending && + !vmx->exit_reason.failed_vmentry) + ++vcpu->stat.nested_runs; + vmx->nested.nested_run_pending = 0; + } vmx->idt_vectoring_info = 0; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5bd550eaf683..6d1f51f6c344 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -243,7 +243,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { VCPU_STAT("l1d_flush", l1d_flush), VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), - VCPU_STAT("nested_run", nested_run), + VCPU_STAT("nested_runs", nested_runs), VCPU_STAT("directed_yield_attempted", directed_yield_attempted), VCPU_STAT("directed_yield_successful", directed_yield_successful), VM_STAT("mmu_shadow_zapped", mmu_shadow_zapped), From patchwork Thu May 20 00:50: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: 12268737 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 1E405C43461 for ; Thu, 20 May 2021 01:39:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF8E5611AE for ; Thu, 20 May 2021 01:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbhETBk6 (ORCPT ); Wed, 19 May 2021 21:40:58 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:53436 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230192AbhETBk5 (ORCPT ); Wed, 19 May 2021 21:40:57 -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 14K1ZTgC188633; Thu, 20 May 2021 01:39:33 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=X9nZzRREkyV+7w0ezhIoXIO70C5RUrZFGycjB+9JfHA=; b=LbBKLNhobZn+yzpfn84dgvXo72oEtyCJPNBtuGRg+yTXVs8gmQKj4/NhaoNmQpt9wOUb UWkJi5IyhEwIzNntRV6lhhmBYm4iKPZVv+JBoAh4yAcunuBOmYtbf5CkTinOixKKKj+/ ds2EVcy+cpEn9CK4fyg/9FFb0fA21GsJsVEFf5S3R0maswOtj5E54dLCsVhhf6D6yj/2 lkyYUvdkYn2oSVEFpZhTSZG3zGW8KQc4Pc1dCp3X1DzqY9yPCVJSYmWwsHaHR6F/502Y /+sdUR9BrQEibVkTWY9qELxPwecKQtIEdOot7Ux4FpP20lIv3JjnBcX4cOIDZag9A6Df WA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 38j6xnk77f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:33 +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 14K1ZNZ5034122; Thu, 20 May 2021 01:39:32 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by userp3020.oracle.com with ESMTP id 38n4918ajc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DwUWAFTV0jq5JcrdKsMJGAKVgBOD9MFjyA2pFLIbs0JNMdTbzUUKvi0tUmJW+/Jt4Siy3kW1/D+lIkWc8Q7F1PjTn8pRsFLxGP0LlDtqoU6cpaCqNRnKhHSUy8qTN32AI/ADQfvI/eG3jbzvLItHLsMAyKtWkZItqZMxAHFWtC8+5HG4tIcuYeCH3I4sVsN7RP/LQY0k9alt7B0+FSotPh+YDOL26IZaqohqrEiQ5yH9qKl876q9TaXViJMCqj/ZYjTAAobzEq3aJowLa+obNsM0GdhpDlWyeVG6ko/8MySdrgNHLwc4Lo9/kERcjLk9VzQQ1DE3Sd2hqyNmSQ5Gcw== 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=X9nZzRREkyV+7w0ezhIoXIO70C5RUrZFGycjB+9JfHA=; b=BgV5xZiIPoCN/XWplLPg7ZojSjKMO7Qpz8PgVgZcXOtvHj1PZb8Xo6JPrzzmdX/xiYHWrSOfXv5pnoxtH1zZkoYFl5SigiRdZLrutkr8EpIEfrMQzZx6kakNPqOYGkgasiKbnqqXfcJS4/Yz4gmCfF2WxAIO4RoQojQ2GnvAaiJNBoSeR0DjLvIrDc9gPciSVuWB31teMDpcO29lDirv17fu+LFKO5OzU0Svlhz4TGW+TF/qNR04wycYAi5J410DrP0oNpCiIpefvSUwcHZAuPIqmUBul1TdoTpXt+oKnnNZPRdz+Um323sUIA1vZ5TIGRQ2RmuoZ2KsXEV9odnJRw== 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=X9nZzRREkyV+7w0ezhIoXIO70C5RUrZFGycjB+9JfHA=; b=udtbQKM/NtzHuYTfiO72V+yFoYxvkbVJA8VRECgtnKcfkZ/UkNCmhhNza6pchD9CNtUQTakpIH1S8PovPk9nON3Ff7Cv+acNnIDfPZxn5vGhnjlltlKYC/QcgCcNqnw5GsL+sTV7IE4k/YnKTNp9e1OcoDAP8OgCTWpA/F3n4C0= 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.4129.28; Thu, 20 May 2021 01:39:30 +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.4129.033; Thu, 20 May 2021 01:39:30 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 3/4 v2] KVM: nVMX: nSVM: Add a new debugfs statistic to show how many VCPUs have run nested guests Date: Wed, 19 May 2021 20:50:11 -0400 Message-Id: <20210520005012.68377-4-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210520005012.68377-1-krish.sadhukhan@oracle.com> References: <20210520005012.68377-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) 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 SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.32 via Frontend Transport; Thu, 20 May 2021 01:39:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f2a70a04-1e54-4e33-f580-08d91b301c6f X-MS-TrafficTypeDiagnostic: SN6PR10MB3088: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1169; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /t6zPW6iYnDrIJVnYPM/OLnIsD0D2G219XsgAVy9ZkDWeJyzHHw2quVqqqeAS/2AvqTJ11n6sQzTPTaPB9Pr14/5UY7mm5VCT4GlVCh8iDdJhF1fMp/My4QNjBvQjvXx3/7i2BAse93KhYw14syMxeexg7GnYRAHrvb9tQSZCMjkJfbXrSAX2BbOfhS5d5eOym479qq3xUYikiuChDa+3DDd3TTe4yJw/BYY01g2cPazgHR81SRYfcLCaeSdDDLTFQFttcqPCMLGIBq2Aw56xKIlgoJE9Kksbwb0qp4GJfo4Ihb5hO7vnOFg44X5gOOn1UGD2Dkgtt4E45QL9Evppw0tLgBycrudEuyhVbsNI5vNi5Y7TtM+P/hgMrQwFcvZHjR/gZl6C3h4H66nCldYjOf7O/UEgScZcxN5GhzxfS2YAGCaxdES7REeppm5T37USz/FvLKJIEHv9vMYI8hNt2jEMhtDvFbShr3af7EK+WeqofQa2uIrBjLlfu506hrYP8nJOU49x5kPGhTgDDoaQrWbOLHZQOvkVZNN13qpKXSTlUE9Gyt2m9Qwv+eEntP4GOAmFCJRX4W1YbRKQvW0z1ZYsU6Ml1bdwABvVRsvXL8jBVgXiWTsS8R8Teo4Y1Jzd1UMd5UVVoLTIy9nMz8wfg== 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:(346002)(396003)(366004)(376002)(136003)(39860400002)(83380400001)(44832011)(2906002)(316002)(66556008)(8936002)(66476007)(66946007)(4326008)(5660300002)(6486002)(36756003)(86362001)(6666004)(7696005)(1076003)(26005)(38350700002)(478600001)(16526019)(38100700002)(186003)(2616005)(6916009)(956004)(52116002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: RA+l6WNtVeazNd+7q1xLgRTq4dHV3lzBj6FtnCCDJmDWncaJCTAWrP9zry/yN/kASb1hSg9H1hwVPb4vLQVVZ5AukozTAPC2ICKtg8hNnUOYFaGv3QUtxbn80wwSWwrUnPlBI3n5oEimRf0eK5FyfBfJIRGKSCyprDxVkVzn7JAIX1a1w2ybYFUEdupEP9TYXjbYsAeQRt6KUOu8AADPycNazTBw5i/fUqAl9xce9ODFGUBSRHrNJqMtqGtEPVbvdcSxVuTh6/M6Aiqh9XODd/63PEmM4asWkdHxd4jbuKCLQ+Tq4Uqvd+pM8dAoPTlFncmdOjIZPYcivgCEddA45IAia3k0dZxpgJE0Kgp5HPTUMdxZlFA/q8bqyeVfYeMipoLRz8SFRBfiElDrGj1mRfyYIAF3vzuRcl8nIDQ2p8oaJJBn0Kfl53XAH5RYYFPDiDhKlM6okw2T2zpJpwCzcAIfJXRg2VWfP0dnJbnacHranlVJLBD7o5va1JD1FQDzTr3HU00p7NnkB9Exgw43N+lcSxnZfC52p/H8IGxP/XRpccMKQkbZUBZiBmmeuxuB6vyRm6pJxx+cnT03jGN7XztF9ZcoAGtnGd7Fxzw3wi/+cF89b5R6TQ0cvhFp9PXaxJzJQCZEyeU1BtdNyqg60+P5wYQ4H/DtOlhVyhUlAh8FGCp88AIxI+KBIT2jNE9yT4vc7Y3sX3/wL3vpOgEoZW9EViZXUZrhqOn9I/EWgwvht6T3y4YnPNlO/4tQCgrihys/7Rtm2uVGgkT9ot1RI1K412Vv9ddDg8lE5p+unbES6m2vfZouqjE9hIDGCLM73aRzBA9P93sp/rNTj+WLGNvFlYzXvq6MaMqdcwoLG3t9+Xd5dOQdE99QCB5Snu+/sdmlgRVn/unZcyVPtZNubSXd0cpZMtLEKShUBiuSCRlvfw5jTl5hNnyt88NVNuUOd3B5qv9xmpwR5eYYqTkUukdr7Ita/EsSIkm1cHQFe2QtavmV2Ng4JA3x9t+CspoJ4jOjt/0jiUkyT0MazJak9snDxpggSLiVB1VTuN1euDT8KAbDfV0Yaks/56hiExToS4JqUiATBtOPqnsD5xM7Y2m+FWKM4pEShhhl7igQ+bm5osd8+hFWa6jg7lk7ZR0fo7shBO8tSGzunf5RSQDW5IiSdaux8w+qafPabk0yipXcE8N/2c0KYRK7suwo7u3OU9+Fp1X3iQ9uYp/dBHqgP8RvhBfdwXrXOAb3lv55CWaN5TAL+w0P0c5KDyrtgVnZ58swIbgZhinSKv+OzU8x6N/tC53I6mc3m44Ritl5y+rZGgW20Cjd511/QGTLWAa5 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2a70a04-1e54-4e33-f580-08d91b301c6f X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 01:39:30.0964 (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: aGUZs2dreHuEsI4Ye198ImymL4CJ/GiYt21P6g8nbdF7g7ihJb/Uo3HMDZccwGCnvNbDAyAIVuLjqshT+mvCo+0MZj2V+ahlwTeizF9B2l4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3088 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 X-Proofpoint-GUID: JXIIsZsPx-owPwYXZBRtp90PsWbk5Q3V X-Proofpoint-ORIG-GUID: JXIIsZsPx-owPwYXZBRtp90PsWbk5Q3V X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 priorityscore=1501 phishscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add a new debugfs statistic to show how many VCPUs have run nested guests. This statistic considers only the first time a given VCPU successfully runs a nested guest. Signed-off-by: Krish Sadhukhan Suggested-by: Jim Mattson --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm/svm.c | 5 ++++- arch/x86/kvm/vmx/vmx.c | 5 ++++- arch/x86/kvm/x86.c | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index cf8557b2b90f..a19fe2cfaa93 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1138,6 +1138,7 @@ struct kvm_vm_stat { ulong lpages; ulong nx_lpage_splits; ulong max_mmu_page_hash_collisions; + ulong vcpus_ran_nested; }; struct kvm_vcpu_stat { diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 57c351640355..d1871c51411f 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3876,8 +3876,11 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu) /* Track VMRUNs that have made past consistency checking */ if (svm->nested.nested_run_pending && svm->vmcb->control.exit_code != SVM_EXIT_ERR && - svm->vmcb->control.exit_code != SVM_EXIT_NPF) + svm->vmcb->control.exit_code != SVM_EXIT_NPF) { + if (!vcpu->stat.nested_runs) + ++vcpu->kvm->stat.vcpus_ran_nested; ++vcpu->stat.nested_runs; + } svm->nested.nested_run_pending = 0; } diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index fa8df7ab2756..dc29aa926be6 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6845,8 +6845,11 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) * checking. */ if (vmx->nested.nested_run_pending && - !vmx->exit_reason.failed_vmentry) + !vmx->exit_reason.failed_vmentry) { + if (!vcpu->stat.nested_runs) + ++vcpu->kvm->stat.vcpus_ran_nested; ++vcpu->stat.nested_runs; + } vmx->nested.nested_run_pending = 0; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6d1f51f6c344..cbca3609a152 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -257,6 +257,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { VM_STAT("largepages", lpages, .mode = 0444), VM_STAT("nx_largepages_splitted", nx_lpage_splits, .mode = 0444), VM_STAT("max_mmu_page_hash_collisions", max_mmu_page_hash_collisions), + VM_STAT("vcpus_ran_nested", vcpus_ran_nested), { NULL } }; From patchwork Thu May 20 00:50:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 12268739 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 CBCD9C43462 for ; Thu, 20 May 2021 01:39:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF529611BF for ; Thu, 20 May 2021 01:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230253AbhETBk7 (ORCPT ); Wed, 19 May 2021 21:40:59 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:41604 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbhETBk6 (ORCPT ); Wed, 19 May 2021 21:40:58 -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 14K1ZAsh154701; Thu, 20 May 2021 01:39:34 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=sMG0Iz+/KrHas4gPDnIyWInsxe60Kluur3VniuLogy0=; b=DrNSN0D5cTzf5X5wvGXnQ7kFX5zLOssZR8QX3ojVP21xau+MpwK9k0TX/SNUs3N5GF+l gt9gbKIVWRVfaOghFoDtjCM7/8UkMXPsRqFzsF9hgCzKfsCHu/Duyc2Dy3fXiO6MfCBS ZImih4eU8pzRZGcy5iLW5CFWPOgutQdP3kXuMOod491/5I8T0Ec3/k1s+TCYPM41AZ3I wCCPu94LbqoZxTkccgDYlriulynuSxnvKtPbhYQaKtgJYZW7KEHOYkyw3F/MMsJMQH4z VzURlidgdOBh5pC3+He9PN9X10EUd8Y44cPbBehx2ZeTfhuktX5gTIGmII86Z98QHnCh RQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 38j5qrb930-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:33 +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 14K1ZNZ8034122; Thu, 20 May 2021 01:39:33 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by userp3020.oracle.com with ESMTP id 38n4918ajc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 01:39:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bp8boXGDt1vVQxi3cKlAC2f4gGGr6B+s4oT+f3/TaehLo8MhdO1viD2T6Dt4gjjtxOFCCY9N18omuUa9vtCRJ/a0a4HX7VgR6nTG3dk8TvX8ruANywUtf1O5jOAfmX8xEhE/gP8agnBAxjIdrCBO8vRAloi+OIVAp4Fvia6TmL6PT/cxolGvxIBzp9QGgrz9JZdoGvMTB/fkso8z9uML6cuHjrDTWDbuVrNfMKDGKvuRUyfc/NQ3doSxcSQM62n9qLRPUUDq1ZBgjZXvFZobFNW1k950+jvxUfq/PiIIJEz2h6myFjmoI+9S6xQ+vIBgQssz2uuMBZOf6ztjIYkF1A== 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=sMG0Iz+/KrHas4gPDnIyWInsxe60Kluur3VniuLogy0=; b=EaZ722g5tmg1Ak1riAPYNmffPLdDD+ZRujBu+u46e0o+1Djvck+WrdgKFqyo3C9mo1Y8IezB+vxWiO8fzXBS5f3zlLBGHl8u1x/7ocF6wIp+wk58Fh/Lecpn6Mz0Rzo67yXNCRffAH+QQpYaDwPDC/8Qi90S6rIJWPboJjuqIw3dkra8mYMlsLzTWbsqkhql2HXE2nFiT2T2NctW9z4E/wQIc3KqwB4gRJzfa+OD6AX6Jewqik/J644uM/BP0Aoik5XVjl08+r3YmrlsINd2UqRrmN8KF+H2i0J59q5jtC7NLvMKLgiufswhVUn8LyuxtaNBvyqqSIQSvN+63zMVfw== 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=sMG0Iz+/KrHas4gPDnIyWInsxe60Kluur3VniuLogy0=; b=N/LLT0z9l7Gi9TKgERrtim6m8lf6vwxu28Jfxq3NLiXk87D32kvmzKXAmVwMQBzikNeqTud8d2qDFzTbKofS0A2fjmlqR1l3TCy3QCDmINbi/0I0KgoX1K8NSQcWJBFAmFauTDGUS5ZTHEVMMlYnp6il9qKOpBx56y+sCqxFJBY= 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.4129.28; Thu, 20 May 2021 01:39:30 +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.4129.033; Thu, 20 May 2021 01:39:30 +0000 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com Subject: [PATCH 4/4 v2] KVM: x86: Add a new VM statistic to show number of VCPUs created in a given VM Date: Wed, 19 May 2021 20:50:12 -0400 Message-Id: <20210520005012.68377-5-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210520005012.68377-1-krish.sadhukhan@oracle.com> References: <20210520005012.68377-1-krish.sadhukhan@oracle.com> X-Originating-IP: [138.3.201.29] X-ClientProxiedBy: SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) 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 SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.32 via Frontend Transport; Thu, 20 May 2021 01:39:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8adcff9f-610f-4196-7d2c-08d91b301cd9 X-MS-TrafficTypeDiagnostic: SN6PR10MB3088: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1IPWZowKqPOaaU8E8thL+6QcVCu1Jnlkjhddn5gfX8K8nXC5ToXExb48fOUcKL3L2fXFTLUup0+u0l+ZQeN0T4NBx3qDs8NuQkHOSgc7c+G2pBNBa0Ma3bpIwEs5TO722CRyR/tha1veKi5T1CZ3RT0fXkJKr5awpEfA8HSg5guND0W8pVeUbMR4r0rHp43NEYaDXq8ut4DSkFutoC8QUkPGRGIsxVrpuZTTw5GhNXqumUid8SbjRNYHG46Zai3hXXUpxg1Rmxunhmajli7505nZ5Xtl0qemfjtoAIFe/SsS6eNz16MvqDSb3x0E6gPisDJyX5UQ0UHGnsgSOiFZWv3bXNy2tJowlsaAp1ViiQGA6Xb57iydypX9HIszXKMMABVOSrc/s3KRu5l3lailUOaycFBssstO4Jfc4HdOte0VKUvj/B0h6bGwCuCaNqqmKVx/rg4epjpXl7sqbUfgxo1lUmg5zZBvunXKQ/XFv4ONykIknO58seki0SpimpRzo/wsyRGAOR6BjDMPP//SCvkZo9dtNd20Q6j3scDGLW+t1whQ6UzszG5/LU2qOzrj8fvxLcIlD9z/4kvsCKPC63ZXqsaPMIuYoQ7GAkP132zrFGUNAwu+8HlrA8H8MmPp9Q1P10v69C+NLb7kTyAnQw== 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:(346002)(396003)(366004)(376002)(136003)(39860400002)(83380400001)(44832011)(2906002)(316002)(66556008)(8936002)(66476007)(66946007)(4326008)(5660300002)(6486002)(36756003)(86362001)(6666004)(7696005)(1076003)(26005)(38350700002)(478600001)(16526019)(38100700002)(186003)(2616005)(6916009)(956004)(52116002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: OZOrvSLB89qMuew0JUTF525f1LIHURDFI1EzwOz/torr9WRl8iplQobB//FS6R7Xzj8TjQJdeAkbQ2odM+4ro7vUmv/Uju1E+XhWPVrobpHSqLPr1e3MlpjUQr68dkw38Oh0g1i72nMt8pNj1VXkbW8sWwvHiFzdwVl7uW98CVcX28fF0NOVp3OweBKeHAcOrBwDyyWsttlzixKApO99Za6i7uGu6Le+jC/mxy7rW3Li1EiHnciZvAfOgdXC449VF2DbdwdOQGQqzPMX5ZWE3yKW21fJqBZsSvJ6KK74H3rvR+7Pu31B/CKlznUXWAQb7TPn7LPL7Pkf3sPOITLH1xq/jsdPTp96lYMETAY+rc+5SVnalabqzeCfK8X1p0nuG0dAMaNJZ2moLl1ZxcJUuPgBwHT35uAZBoTsaEPiRN5PVD5VDwKhTre7hBy3Q5zvwlTbJ+7PhVIEk8AEUKtnPfARqrFyi1t3nsPU8s/O4ySgPJnLGBAA/8jTDeylgR/u3EFXC45PAzRhp1bkGjvM8r4GEc7yG5HwFFoonTr8cq39REpyHQXkDMqWpIhMXjGH30MnbxhuP5YqkN2fSnUitS0N7D3Ut8Ue0BI4mWPzPtur1tpdRtUOYaqj56fqaiMu7q++c2h/Y+5nGe2MNQkgr3uADwipygFNYY0mYVgkMw4Ysgbz7XAVB/+efR8WuXufcKOTt+tHEyXkz6mbhHb/fxPO8NiGaubQspLWf04uY1etmINcWUbC1hXzB/aZKLHfhKlAn3DLpllhBnowlX8F47r780iNMLtgsxjFYfTlA6+niw9NYqlx0YQW5VxKF1e47XRcPnDpLfaDPaRpQ/nagyq+HElRgk2wwwA5RHWBulRUj3dgRSKjMIOcaHWU4bxyMpp3xENHe3Yy8iXXXgE354XCNQSju91pSdNh5KtP17pMWfTGvwapjTonkffef+uUQgjxpIIiouv/zOWFAO6HN2ydXBJjAgCqfTko36x+dlPZ8XJmw6VYfDNW2QHIHFytRebOw64duPdK99ecwC8asjRDpMZHaRe4DO2kiGyQWP7JMJSZKP1UcYjMZ3+gjQz72Ci2dZkOoGeHhQrv2pIj60MfAhAu7ao99OWD13lzjsMRRiUpUhDZt8S5W5/DsKo2jtGyn5Qo+gB5LxBoDrkvFrWGXVNDsSRkrSgefr1eU6t/0QDkPMFpXYKC1twt5Rc0tX/3qzkzq5rbjh9gP7sk9ETEgSMWL2tXoECSqSKEPls2Iog2DeDI/nT6t1ikycsTAPCT+wokP0+4R7Y9hKnM2HJIeM7Z8SKJZT+19/LYkwzmBDbY2gKuaCgW03+IEgTs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8adcff9f-610f-4196-7d2c-08d91b301cd9 X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3021.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 01:39:30.7870 (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: LBJt3Sop59Cu+cBoW4UYt1AM/an06sJWXvPIXbNq753ef/OcH9+kSZZau8OzVVePIz4wObhdlwEXo1YaHT8U1FJciUFN18i8mAA72dFRfQs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3088 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 X-Proofpoint-GUID: 2QjDaFEBh1dyaTIqgbbnQhPNVC053EOo X-Proofpoint-ORIG-GUID: 2QjDaFEBh1dyaTIqgbbnQhPNVC053EOo X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9989 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 adultscore=0 priorityscore=1501 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200007 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 'struct kvm' already has a member for counting the number of VCPUs created for a given VM. Add this as a new VM statistic to KVM debugfs. Signed-off-by: Krish Sadhukhan --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm/svm.c | 3 +-- arch/x86/kvm/x86.c | 1 + virt/kvm/kvm_main.c | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index a19fe2cfaa93..69ca1d6f6557 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1139,6 +1139,7 @@ struct kvm_vm_stat { ulong nx_lpage_splits; ulong max_mmu_page_hash_collisions; ulong vcpus_ran_nested; + u64 created_vcpus; }; struct kvm_vcpu_stat { diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index d1871c51411f..fef0baba043b 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3875,8 +3875,7 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu) /* Track VMRUNs that have made past consistency checking */ if (svm->nested.nested_run_pending && - svm->vmcb->control.exit_code != SVM_EXIT_ERR && - svm->vmcb->control.exit_code != SVM_EXIT_NPF) { + svm->vmcb->control.exit_code != SVM_EXIT_ERR) { if (!vcpu->stat.nested_runs) ++vcpu->kvm->stat.vcpus_ran_nested; ++vcpu->stat.nested_runs; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index cbca3609a152..a9d27ce4cc93 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -258,6 +258,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { VM_STAT("nx_largepages_splitted", nx_lpage_splits, .mode = 0444), VM_STAT("max_mmu_page_hash_collisions", max_mmu_page_hash_collisions), VM_STAT("vcpus_ran_nested", vcpus_ran_nested), + VM_STAT("created_vcpus", created_vcpus), { NULL } }; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 6b4feb92dc79..ac8f02d8a051 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3318,6 +3318,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) } kvm->created_vcpus++; + kvm->stat.created_vcpus++; mutex_unlock(&kvm->lock); r = kvm_arch_vcpu_precreate(kvm, id); @@ -3394,6 +3395,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) vcpu_decrement: mutex_lock(&kvm->lock); kvm->created_vcpus--; + kvm->stat.created_vcpus--; mutex_unlock(&kvm->lock); return r; }