Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp643335pxu; Fri, 23 Oct 2020 09:38:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9HwFUKZw38RnS9mnGeZL+FLzbUfin4IOgb+ziuei/km+FLnDZ4aqYAGYvoezmt7R1FGeL X-Received: by 2002:a05:6402:1447:: with SMTP id d7mr3103369edx.158.1603471135131; Fri, 23 Oct 2020 09:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603471135; cv=none; d=google.com; s=arc-20160816; b=cJS3esENxwWklxz1VCze5dYehAUv+SlHc3x2KbB9l95D5rZX4Cmg3DWPKhUe4OccPz PfXM4dcN3tgoooA8Ho7R+cCFPFkl1bbG6FJs+cfxCFbDVwIprFF4B7zIVkrpT1rJaQ7r 2+JFSX1v/3PwcYfcLtS+cmheIrByu+xdmU6ctCqSQ4D3Q7gt74PPsDaN5FX1RtX6uFdK avTySSPTc3NO82OzqVZOYtANZC3aGEL9Lo5qNikf/PUX61kEfxbqMaargI8y46JSB5OF pY7hvMeUqKp7iiVQro2cokvw1SD42vzUH47a5QmcUH7t+x8BvGzZNrsQTadEYC4pTtuM uAMg== 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=vZys5VvhSQ6/2I5CVfBFXnNyeXP4aUtEsSNzlhlUY5w=; b=O2Ao+hojVCO8Y2hDUL3Ap3EbGntGnMAHBxL3gAH0bK4coMheADKY9dZLCcXXaevULi Cum2Ybe5SWc37hGjuPxpdTq/YiS7FxXSjMbxoeQZtUUlGP4yTMeVFbVTGne8rSt4eJ/T DYNFPgBMxWzs9hsUb5USb4M0+CSq07jRYB8n7SPo/N3a1ddb9qI7DmuYaeHijp8JGXkU joT5UD19OWjUz/1BEGHT7vv+iaLIZgcGVm8UtKCbUf9IH7LxraWgWuHy0PJU6jTYA9Yq wYrycbUlbpL3cjg5PRTEAigqCHsD5yQ8aC6BMhrwt07n1rYSa2rL0QrcWp/rRA/quXs/ EVlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jFuyfUfd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si1454145ejx.254.2020.10.23.09.38.32; Fri, 23 Oct 2020 09:38:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jFuyfUfd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1751733AbgJWQbe (ORCPT + 99 others); Fri, 23 Oct 2020 12:31:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20272 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbgJWQan (ORCPT ); Fri, 23 Oct 2020 12:30:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603470642; 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=vZys5VvhSQ6/2I5CVfBFXnNyeXP4aUtEsSNzlhlUY5w=; b=jFuyfUfdwc7I4OLdefEkEyWzDGUPxmjM8WrxwTbLnYbA7shcYtR40p1X2OXOFF3LUXxhaq ABNAM8x1SgJtDU4oNT3tsUAeNlVui6hdXQVn+Ki9P8Au41N0GmjxK6TlQUfjQI0pu5SpUs s0Peqiy9wFxfzY7e3denaa09Whn6pG4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-u_SGprxJP-GZpMjh6iOzbw-1; Fri, 23 Oct 2020 12:30:37 -0400 X-MC-Unique: u_SGprxJP-GZpMjh6iOzbw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 428C3E9000; Fri, 23 Oct 2020 16:30:36 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64A475D9E2; Fri, 23 Oct 2020 16:30:29 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: bgardon@google.com, Peter Xu , Sean Christopherson Subject: [PATCH 09/22] KVM: Cache as_id in kvm_memory_slot Date: Fri, 23 Oct 2020 12:30:11 -0400 Message-Id: <20201023163024.2765558-10-pbonzini@redhat.com> In-Reply-To: <20201023163024.2765558-1-pbonzini@redhat.com> References: <20201023163024.2765558-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Xu Cache the address space ID just like the slot ID. It will be used in order to fill in the dirty ring entries. Suggested-by: Paolo Bonzini Suggested-by: Sean Christopherson Reviewed-by: Sean Christopherson Signed-off-by: Peter Xu Message-Id: <20201014182700.2888246-7-bgardon@google.com> Signed-off-by: Paolo Bonzini --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 05e3c2fb3ef7..c6f45687ba89 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -346,6 +346,7 @@ struct kvm_memory_slot { unsigned long userspace_addr; u32 flags; short id; + u16 as_id; }; static inline unsigned long kvm_dirty_bitmap_bytes(struct kvm_memory_slot *memslot) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 68edd25dcb11..2e8539213125 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1247,6 +1247,11 @@ static int kvm_delete_memslot(struct kvm *kvm, memset(&new, 0, sizeof(new)); new.id = old->id; + /* + * This is only for debugging purpose; it should never be referenced + * for a removed memslot. + */ + new.as_id = as_id; r = kvm_set_memslot(kvm, mem, old, &new, as_id, KVM_MR_DELETE); if (r) @@ -1313,6 +1318,7 @@ int __kvm_set_memory_region(struct kvm *kvm, if (!mem->memory_size) return kvm_delete_memslot(kvm, mem, &old, as_id); + new.as_id = as_id; new.id = id; new.base_gfn = mem->guest_phys_addr >> PAGE_SHIFT; new.npages = mem->memory_size >> PAGE_SHIFT; -- 2.26.2