Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1053461pxb; Wed, 3 Nov 2021 17:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfEmSiEZzwinSplTGmKkbIK3ICqPd9TTjP1SHwWuh5qUDDrcbZLUUojLTvaAcFymTS5Voa X-Received: by 2002:a05:6638:a2d:: with SMTP id 13mr1317220jao.12.1635985778023; Wed, 03 Nov 2021 17:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635985778; cv=none; d=google.com; s=arc-20160816; b=LclUWiAVcOHflyXsgrsC1aNkvG/Br/DPQYuoo2H6oGARJfiLnQKiPVhRpGr2Ofe/ui 0DXMrvLVP3V43SHB3lka2W3vz1sP0ybqGEUooNinl8CVcitj9I0YJIEUqO4TKm0xdqWZ 5oNn6FrIrD8lHb9Z9RC3MljVU/otiFm3WfPQpuI/s9vrTjLZ0JX4cDLomaVUSHQJSNf8 dCuHeHr2/zl7mhTCRet0zZWbgd1kkfzdpPbffYMmhN1x5jFZI8naAO9tVhwSjD1nJqrh OHgDWNol7JR8R2WcqIZ067JOB8/3785/s4AhYefrZm/WYt6HEiW90hXoaL6Y6AeGO6nZ ddcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=tLQvwVMFuRU1rudmVd+Ot8DGDwWCKV2XWE4z9OvxcSI=; b=qEx15YF8u8iLhJy8CmwMjp6sP9Wn7bXeYSWTYtg94RTGUEk4FCDOiy7t/eULmjLiQx 1l8DqowaxuQnNWRWvKp+LV8qehnOtu1YK5IK6iy880pZJCi8J731OhfUpThzznnizJBW XEZdA/kQTa1xVltoFOdRX0BQlc1uO3jdL4/BF3CTbP9aMPpvSFUzKpTkyevQbQW7vGOe +LWpbaj/Lb/pRACiYYAeKZwgc6s49OAFHPAirSkSgyKNfLAZd8yu9HUHYCWYW9zjDRjG koY1oWd5yZemsTH2tvZNphHsuSYkt4Q+C5jP+IS+HuvhaupIBpN5yX/8B7i8JIeGdx9i bhVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aidjRg10; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 1si360749ilz.178.2021.11.03.17.29.25; Wed, 03 Nov 2021 17:29:38 -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=@google.com header.s=20210112 header.b=aidjRg10; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233142AbhKDAaa (ORCPT + 99 others); Wed, 3 Nov 2021 20:30:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233219AbhKDA2t (ORCPT ); Wed, 3 Nov 2021 20:28:49 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC84C061205 for ; Wed, 3 Nov 2021 17:26:12 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id w8-20020a170902a70800b0013ffaf12fbaso1900612plq.23 for ; Wed, 03 Nov 2021 17:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=tLQvwVMFuRU1rudmVd+Ot8DGDwWCKV2XWE4z9OvxcSI=; b=aidjRg109rDQhcbEOaDvYUP/J6xeFiJXWQHPB/9inpIU47CGJj4EB+RwhcIG070Mie lVHTfvEeNG2Brzpgw8EZNdAVeUVZ4nNqCUo0Ix5XLJ0H18oJo/2rFOKMzl6fWLSJY191 J6xXKGp+3siToXIqVebLKzjgDI+yAMnV78lg50hWKNPX/pVq2TrOflawSIczG+Lqobke Z0ZzafsHPcdo8PEDuhw/rn2m58dsopFaT3sRkFsFmilo83Ii5s7nnixu4BD3y0cdffxJ kzs8TJbXMv5IItYIkJSv/EhZBtHn1F5Yu5VOIhoRSGmVNkoq+MSSDwRM5budJwMaPSM5 i1ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=tLQvwVMFuRU1rudmVd+Ot8DGDwWCKV2XWE4z9OvxcSI=; b=dEnB+wWBf52ZkKZh7fbEpZendwR7z5DiiXUkB2u4dA5AqjQzVwrDeI6gOP+VV6Fs8B L4cHZbu4uUI+I3HRLje1BibIhgH4g7y7BPfHMH7ioSBhRUs4bE7mdHZ0hHUe3EWKECss i5xEtiSBx/MbWzku61mT9QBSzcc4YY4+TwS/QwupYv50bF3vOvFz2HOYmxFaKOnzBpSF PbPiBr6eC4is70/r0h0Zj5UvBhBVV8RRWCCiN+TA0Rvc8ifWi4sX63tLy5Yl2+e9TOZU mk92oUYKbpIiUAs8C9HbX6SMSqMigH0i3Ktzggwszhd2VeNVi9pLZPuu8yaL65nOGBLK 1WGw== X-Gm-Message-State: AOAM530Zf9UEHpZO/8/kF5r7V2WFvjuNaoFhvdGl8sH7kwfdTwW4kz+Z 1p6kXCafvIa1qYFniEHikNoLO+yB/bU= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a05:6a00:1484:b0:48c:2e58:8d39 with SMTP id v4-20020a056a00148400b0048c2e588d39mr11085289pfu.13.1635985571770; Wed, 03 Nov 2021 17:26:11 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 4 Nov 2021 00:25:09 +0000 In-Reply-To: <20211104002531.1176691-1-seanjc@google.com> Message-Id: <20211104002531.1176691-9-seanjc@google.com> Mime-Version: 1.0 References: <20211104002531.1176691-1-seanjc@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v5.5 08/30] KVM: arm64: Use "new" memslot instead of userspace memory region From: Sean Christopherson To: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Ben Gardon , "Maciej S . Szmigiero" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Get the slot ID, hva, etc... from the "new" memslot instead of the userspace memory region when preparing/committing a memory region. This will allow a future commit to drop @mem from the prepare/commit hooks once all architectures convert to using "new". Opportunistically wait to get the hva begin+end until after filtering out the DELETE case in anticipation of a future commit passing NULL for @new when deleting a memslot. Signed-off-by: Sean Christopherson --- arch/arm64/kvm/mmu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index cc41eadfbbf4..21213cba7c47 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1473,14 +1473,14 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, * allocated dirty_bitmap[], dirty pages will be tracked while the * memory slot is write protected. */ - if (change != KVM_MR_DELETE && mem->flags & KVM_MEM_LOG_DIRTY_PAGES) { + if (change != KVM_MR_DELETE && new->flags & KVM_MEM_LOG_DIRTY_PAGES) { /* * If we're with initial-all-set, we don't need to write * protect any pages because they're all reported as dirty. * Huge pages and normal pages will be write protect gradually. */ if (!kvm_dirty_log_manual_protect_and_init_set(kvm)) { - kvm_mmu_wp_memory_region(kvm, mem->slot); + kvm_mmu_wp_memory_region(kvm, new->id); } } } @@ -1491,8 +1491,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, struct kvm_memory_slot *new, enum kvm_mr_change change) { - hva_t hva = mem->userspace_addr; - hva_t reg_end = hva + mem->memory_size; + hva_t hva, reg_end; int ret = 0; if (change != KVM_MR_CREATE && change != KVM_MR_MOVE && @@ -1506,6 +1505,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, if ((new->base_gfn + new->npages) > (kvm_phys_size(kvm) >> PAGE_SHIFT)) return -EFAULT; + hva = new->userspace_addr; + reg_end = hva + (new->npages << PAGE_SHIFT); + mmap_read_lock(current->mm); /* * A memory region could potentially cover multiple VMAs, and any holes -- 2.33.1.1089.g2158813163f-goog