From patchwork Thu Nov 17 14:32:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 21683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp433244wrr; Thu, 17 Nov 2022 06:35:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf57e1Ap7/r0e62JzTGR95ExV+VOac351HOygesPHYw8vvwRpvlMBhNdegNWTpqYQQTl3oFW X-Received: by 2002:a63:5946:0:b0:470:3fc0:3d8c with SMTP id j6-20020a635946000000b004703fc03d8cmr2240001pgm.446.1668695718113; Thu, 17 Nov 2022 06:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668695718; cv=none; d=google.com; s=arc-20160816; b=KwGf4Jcrw6JHuBRc1/+TLr+W6ZQ3/9ecJ/W6y0uxV86Ra+FRc/uRYcx7Q5dRE+EBGe CKKVuuobSIC9dVpiEB9yHmfYw1kir9aXOP5D5cY9BwbuCAZg1dzOWndcJN2IxgzQurTe rcpglNcnLcunUn3+NQAXtcbkrs6iC6kbE/XH96qeJusiuGEQVcKYn/om3ZlKY/9xpyi8 3KsR5R6PghuttNZ/RNTYf9B9S/EF5ZfREPeYgNZdfswRz4mi6gBVFo0ywwUvkufrDzYa 9iz71168hSkddRo8P1Hk3A6Cf+Q8+XkkERk47T4YYakSaN7j1r6yuNisGN6yxlrny3BF 9/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Frw/bhnQ/fgaTcwMRmhjoEhY2NlH0mLgodVAsiEeP10=; b=QzawRF5wAQvH2Ezv31zl7sO9yB+dClr6K13Gd2ykJ/rVKhWcfmeEdZ7HfJOjo9hZZW 1F4TWvOq9lqlhsDpwpKy0NUcgDohlg/bpM7qylR9TnKCtnsEUyyUnLPsPcXHBRAWy0BI Waj7hhok6C6rUGMBCfcysgvYFysnmoYQP52sjQuRSFtQ9ocYeSCGkHWtlPtad7jiBoOR 9NL6K2GpS2xlJMJlstDb23Fujz43i9XpuzdPoF+lh0fQATybsTCwqDBXejRv8VGjGCbG LiIEjGqdGwe79CY0wtoTpJrlYr1FhfHH3AdYFC/IQbtVBlwm9gpL6F1cwJO8Yy10W+TG wDJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="M/egedW2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a170902ce8200b001869394a38dsi1217122plg.503.2022.11.17.06.35.02; Thu, 17 Nov 2022 06:35:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="M/egedW2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240439AbiKQOed (ORCPT + 99 others); Thu, 17 Nov 2022 09:34:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240248AbiKQOeI (ORCPT ); Thu, 17 Nov 2022 09:34:08 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ED7279E36 for ; Thu, 17 Nov 2022 06:33:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668695584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Frw/bhnQ/fgaTcwMRmhjoEhY2NlH0mLgodVAsiEeP10=; b=M/egedW2fnnIy0yipWmUtvABP2vtOkGAO6qEYiDOhmWTslB7Ugruek72D2hacJgiVbALrB Hh092ZfONnzmAYAMzLxErfO8/sg8NVJNpMTp9PLphckw3+Ocv+ny3lzxjiP6Wh6JaGuVtx b9sojq7TQnNBgE5/f7ef2LNx0S1vLLM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-274-CYSwL3jhOAizB5te_RPptQ-1; Thu, 17 Nov 2022 09:32:59 -0500 X-MC-Unique: CYSwL3jhOAizB5te_RPptQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F9D2185A794; Thu, 17 Nov 2022 14:32:58 +0000 (UTC) Received: from amdlaptop.tlv.redhat.com (dhcp-4-238.tlv.redhat.com [10.35.4.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19A852166B29; Thu, 17 Nov 2022 14:32:54 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Paolo Bonzini , Ingo Molnar , "H. Peter Anvin" , Dave Hansen , linux-kernel@vger.kernel.org, Peter Zijlstra , Thomas Gleixner , Sandipan Das , Daniel Sneddon , Jing Liu , Josh Poimboeuf , Wyes Karny , Borislav Petkov , Babu Moger , Pawan Gupta , Sean Christopherson , Jim Mattson , x86@kernel.org, Maxim Levitsky Subject: [PATCH 03/13] KVM: nSVM: rename nested_sync_control_from_vmcb02 to nested_sync_int_ctl_from_vmcb02 Date: Thu, 17 Nov 2022 16:32:32 +0200 Message-Id: <20221117143242.102721-4-mlevitsk@redhat.com> In-Reply-To: <20221117143242.102721-1-mlevitsk@redhat.com> References: <20221117143242.102721-1-mlevitsk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749754281286994309?= X-GMAIL-MSGID: =?utf-8?q?1749754281286994309?= The nested_sync_control_from_vmcb02 name is misleading as there are many fields which are modified by the CPU and need to be written back to vmcb12. This function only copies some int_ctl bits and thecevent_inj* fields. Make it copy only these int_ctl bits and rename the function. Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/nested.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 91a51e75717dca..54eb152e2b60b6 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -404,15 +404,13 @@ void nested_copy_vmcb_save_to_cache(struct vcpu_svm *svm, } /* - * Synchronize fields that are written by the processor, so that + * Synchronize int_ctl fields that are written by the processor, so that * they can be copied back into the vmcb12. */ -static void nested_sync_control_from_vmcb02(struct vcpu_svm *svm, +static void nested_sync_int_ctl_from_vmcb02(struct vcpu_svm *svm, struct vmcb *vmcb12) { u32 mask; - vmcb12->control.event_inj = svm->vmcb->control.event_inj; - vmcb12->control.event_inj_err = svm->vmcb->control.event_inj_err; /* Only a few fields of int_ctl are written by the processor. */ mask = V_IRQ_MASK | V_TPR_MASK; @@ -986,7 +984,10 @@ int nested_svm_vmexit(struct vcpu_svm *svm) if (vmcb12->control.exit_code != SVM_EXIT_ERR) nested_save_pending_event_to_vmcb12(svm, vmcb12); - nested_sync_control_from_vmcb02(svm, vmcb12); + nested_sync_int_ctl_from_vmcb02(svm, vmcb12); + + vmcb12->control.event_inj = svm->vmcb->control.event_inj; + vmcb12->control.event_inj_err = svm->vmcb->control.event_inj_err; if (svm->nrips_enabled) vmcb12->control.next_rip = vmcb02->control.next_rip;