Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp177720pxb; Tue, 15 Feb 2022 10:47:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNM6ayQykC5FdFaDzX7dTPVjQj21SW3iY/Z39f1NzYMM8Jm0EnTvSsqjTkXxgbjaX+puti X-Received: by 2002:a17:90a:19c2:: with SMTP id 2mr230924pjj.132.1644950820328; Tue, 15 Feb 2022 10:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644950820; cv=none; d=google.com; s=arc-20160816; b=rjAX9xkGWml6s1g10bVmiJhWCiREmALcyYp1iIxWMhlPBtwWn9neI/JPL8yo3GTw6g ZRiVRihPzqY5cxgCiNniUEcxNLXx2tloEv9YKga9JtTRU1U0cjYOM3viMEZWbNIsRcM1 svv9HmglgYDJ6mO4YZi5Qti7YTBVC0n/sJJxUe4vAMXONVTdaT2Lz2qxPIGZTLYt/RkB hPuSiVQlDX4bzE3mr7NpBOA8zamt9NCoDCA/fJI4QT7oEMht7ldd8NhUlHjKVCjmOdue MJuogyr1AJNZhZ0SlndHAb2vaaSxcs1di5UztjURLWKOIGh77X9KCs4MjPV+//9U/aCd 9nfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IMlwVgzQyz7Ol8ZT8u19HUTMM/hLQV/cI9HesozCSG8=; b=Geb4bEncVEKWElPISAQyjiFbUr0NQrGDm6QkAWXMBfuhCbZHXossPLEncWWEcybRkU CbTfRVYQDqWdx6tfe9Lrb1fiiBfaZ92Dh9z5vFdslfWqoARAMN17aZnZePnRMybopeUz OmQ3iyKALhvUVuNzYO/3FBewh6U3EZ80Fk/SFM207r6sWob2uT+031W3A/uZpr6IZLi/ bRbaykciSWhoTnfNb6U7S1luPD2ol9pqjSPUy8lGpSGTmeMgSOjrfpa7kyoXTjtiFV9T Q68CDXZwDHg0iBNAY/lT3MC6ybAEZoNLJzCY/FqkBriRHMv4OFmze3dhWrn/UcusF/U9 JWXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rv5yFZJG; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q141si3388826pgq.557.2022.02.15.10.46.43; Tue, 15 Feb 2022 10:47:00 -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=@google.com header.s=20210112 header.b=rv5yFZJG; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbiBOQbD (ORCPT + 99 others); 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-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> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 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.