From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2710C433F5 for ; Tue, 15 Feb 2022 16:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241190AbiBOQbD (ORCPT ); Tue, 15 Feb 2022 11:31:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236490AbiBOQbA (ORCPT ); Tue, 15 Feb 2022 11:31:00 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 743BAE44BA for ; Tue, 15 Feb 2022 08:30:49 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id z16so13841056pfh.3 for ; Tue, 15 Feb 2022 08:30:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IMlwVgzQyz7Ol8ZT8u19HUTMM/hLQV/cI9HesozCSG8=; b=rv5yFZJGQlEFyPHLOy7He2hHDb9greGfCVmwWDwf0yl2jLGg2jOUGs5o3LYdZ7Ey0G xdQoOlr2Qod/ywdeUAwIKDJTZY5F9CgIiBof1UsxvpX+Tgny/nAD/pICZoVluQ2ZPANM tSG2Sa0AypXLntNY6Oq8kwO6/IYOkFcrYiTVXNKgZMrOjSi4ZGqhdkHWtymjaNM9+DcX PpG67b9PgbZ2KY7XIMAxDdUvdsYyF5pwjJoqiSCVSlPCIfy3KWqWuy2lJy0z13lcRoAl sGLxCU1I5WZQNr9kWEp0Bbbk0bl1I6HVzFueTr5EoZ9awKNh+FXVIvAi8mf6pqHDh7sK +S8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IMlwVgzQyz7Ol8ZT8u19HUTMM/hLQV/cI9HesozCSG8=; b=d8saLkh1WvMlZ3wGUB8gpoN+A+yiescPEyc6fKoLJjATUGbi/fn/YUf29Kp41qFnOf 23jYmv2NBI9QETILlreFN11MRxW/WSmqj9fbUWZR9zOYg1wuveE7Fy33xYJIueINyoKk 6YWnqDUm5NYvV4CoTjOwIVMbMxTI+CgHcpl9oHP18Bx6wDc7bv/kGsz23rwCCQwAR6vN msR0EUM6K5Xqhk0duR6nEJfhE8lJvAZCPlt3qT/81JgZikfLkAB2Ib+ytT8WbUuvEIaz /QMAH+Bxjvx8sU1eVLwxbklfkAAZ0LqyMSg66VLPcbXb7Ouw5G6IAab8dL8CXDWy5LZg sazw== X-Gm-Message-State: AOAM531wKc/DWRs8VP1QXKP6f1brlDXXkYgDXrvP94IAK2j2yN93SDIH /ewOPaOH+cMkW6eD0lIR2us0lw== X-Google-Smtp-Source: ABdhPJys3WpZBgOoj61fy1187jRwIkgBsulC+N7VKcxf5cs9IIigOisBdFNqUCLMSF85SYBXamcsHQ== X-Received: by 2002:a05:6a00:804:: with SMTP id m4mr4897245pfk.45.1644942648750; Tue, 15 Feb 2022 08:30:48 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id s2sm9254976pfk.3.2022.02.15.08.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 08:30:48 -0800 (PST) Date: Tue, 15 Feb 2022 16:30:44 +0000 From: Sean Christopherson To: Chao Gao Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zeng Guang , Maxim Levitsky Subject: Re: [PATCH 02/11] KVM: VMX: Handle APIC-write offset wrangling in VMX code Message-ID: References: <20220204214205.3306634-1-seanjc@google.com> <20220204214205.3306634-3-seanjc@google.com> <20220215022221.GA28478@gao-cwp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220215022221.GA28478@gao-cwp> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 15, 2022, Chao Gao wrote: > >--- a/arch/x86/kvm/vmx/vmx.c > >+++ b/arch/x86/kvm/vmx/vmx.c > >@@ -5302,9 +5302,16 @@ static int handle_apic_eoi_induced(struct kvm_vcpu *vcpu) > > static int handle_apic_write(struct kvm_vcpu *vcpu) > > { > > unsigned long exit_qualification = vmx_get_exit_qual(vcpu); > >- u32 offset = exit_qualification & 0xfff; > > > >- /* APIC-write VM exit is trap-like and thus no need to adjust IP */ > >+ /* > >+ * APIC-write VM-Exit is trap-like, KVM doesn't need to advance RIP and > >+ * hardware has done any necessary aliasing, offset adjustments, etc... > >+ * for the access. I.e. the correct value has already been written to > >+ * the vAPIC page for the correct 16-byte chunk. KVM needs only to > >+ * retrieve the register value and emulate the access. > >+ */ > >+ u32 offset = exit_qualification & 0xff0; > > Can we take this opportunity to remove offset/exit_qualification? > They are used just once. Definitely should have dropped exit_qualification, not sure why I didn't. I'd prefer to keep offset to document what is held in vmcs.EXIT_QUALIFICATION without having to add an explicit comment.