Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1194218ybl; Wed, 18 Dec 2019 14:25:13 -0800 (PST) X-Google-Smtp-Source: APXvYqx1bifxbFTsCcNeTvWrN2zynWNW0ZkjBpYTGymvIP5yrZrU+QaYpW3G3ud9YgIrJY+iV+z6 X-Received: by 2002:a05:6830:1d7b:: with SMTP id l27mr4815722oti.251.1576707913443; Wed, 18 Dec 2019 14:25:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576707913; cv=none; d=google.com; s=arc-20160816; b=aeIijDaPvemfE9N/JovENQoZefcmaVLba7ksYqpDbA59m0pkaigx7XWwmC3lNyzR/T H2Qsfb767/7MCSxeqO4NAH4KPw9F3mdfhLiNZN7u8T6gupgnzg3VyhH5Mmeszzg73571 CtmK5Lz/GuIFrRmciHMl9bCREA79TZfBE478hbMcIpNlqhx5unQCl7dXThzPh2eRSFXE pp5GYqLKtcKapYAsFTlz/fl2+Phtoz/LvRX/oTzhsz+hMLOPWMSOgKIIGxntTHBd8uL9 au1kHUHlmt2qeXH4K62G0d1KfWreNHkozrllPPmQW4loq0uLHDdRNPvQTL5In6/EhBsD 531Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/55NanoX4GYJ71DAXj/w4ahmRFlDynvLWw7axTw2Lys=; b=iAGp5Kn8laAetSfwWX7N/1aUHaBBvFxl0dhM2v0NkwabfWJxkTz0I+I1KQO3cZAmQq +Lndj813+IZJNv5OtrHzJFaJo+aVQ+895gMP2/2jXgZsXV72MCrsKK3w2myjXRSWyLAm WgKwZTmU2cpUHL7MQOWFhChubIbMQ4+ED6sJXCpYVJpEEl+506kJstdrwiA5qTwd0Gf2 UIDikSUF3rqv6C8dei6zTQDbMCjQdIyDEKHdmDF7LKYlO5/K+Sp/Ba8EKDbk9gczUnvi lTGOrD5IjoDXfOID3xlKgVMpG26lAMHWbNK1BdHZzo1L44fdLuXiT4wIwQcGPjlMA6bY elLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si2195788ota.19.2019.12.18.14.25.01; Wed, 18 Dec 2019 14:25:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbfLRWYW (ORCPT + 99 others); Wed, 18 Dec 2019 17:24:22 -0500 Received: from mga06.intel.com ([134.134.136.31]:25121 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbfLRWYW (ORCPT ); Wed, 18 Dec 2019 17:24:22 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2019 14:24:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,330,1571727600"; d="scan'208";a="213054124" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by fmsmga008.fm.intel.com with ESMTP; 18 Dec 2019 14:24:20 -0800 Date: Wed, 18 Dec 2019 14:24:20 -0800 From: Sean Christopherson To: Peter Xu Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "Dr . David Alan Gilbert" , Vitaly Kuznetsov , Alex Williamson , "Tian, Kevin" Subject: Re: [PATCH RFC 04/15] KVM: Implement ring-based dirty memory tracking Message-ID: <20191218222420.GH25201@linux.intel.com> References: <20191210155259.GD3352@xz-x1> <3e6cb5ec-66c0-00ab-b75e-ad2beb1d216d@redhat.com> <20191215172124.GA83861@xz-x1> <20191216185454.GG83861@xz-x1> <815923d9-2d48-2915-4acb-97eb90996403@redhat.com> <20191217162405.GD7258@xz-x1> <20191218215857.GE26669@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191218215857.GE26669@xz-x1> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 18, 2019 at 04:58:57PM -0500, Peter Xu wrote: > On Tue, Dec 17, 2019 at 05:28:54PM +0100, Paolo Bonzini wrote: > > On 17/12/19 17:24, Peter Xu wrote: > > >> No, please pass it all the way down to the [&] functions but not to > > >> kvm_write_guest_page. Those should keep using vcpu->kvm. > > > Actually I even wanted to refactor these helpers. I mean, we have two > > > sets of helpers now, kvm_[vcpu]_{read|write}*(), so one set is per-vm, > > > the other set is per-vcpu. IIUC the only difference of these two are > > > whether we should consider ((vcpu)->arch.hflags & HF_SMM_MASK) or we > > > just write to address space zero always. > > > > Right. > > > > > Could we unify them into a > > > single set of helper (I'll just drop the *_vcpu_* helpers because it's > > > longer when write) but we always pass in vcpu* as the first parameter? > > > Then we add another parameter "vcpu_smm" to show whether we want to > > > consider the HF_SMM_MASK flag. > > > > You'd have to check through all KVM implementations whether you always > > have the vCPU. Also non-x86 doesn't have address spaces, and by the > > time you add ", true" or ", false" it's longer than the "_vcpu_" you > > have removed. So, not a good idea in my opinion. :D > > Well, now I've changed my mind. :) (considering that we still have > many places that will not have vcpu*...) > > I can simply add that "vcpu_smm" parameter to kvm_vcpu_write_*() > without removing the kvm_write_*() helpers. Then I'll be able to > convert most of the kvm_write_*() (or its family) callers to > kvm_vcpu_write*(..., vcpu_smm=false) calls where proper. > > Would that be good? I've lost track of the problem you're trying to solve, but if you do something like "vcpu_smm=false", explicitly pass an address space ID instead of hardcoding x86 specific SMM crud, e.g. kvm_vcpu_write*(..., as_id=0);