From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65842143744 for ; Thu, 1 Aug 2024 18:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722535293; cv=none; b=Fgr38E84Gce5jj7QGQD6TIIusLDOCaHzTjjVtdd4c2DRN05N9T7MtrNr4vKbMlI3S1Mg3N+GqvE5jWLEoX7kWpY5NCDTvlSqlwfuNWWr4sGwKSIonp83+RR7RrQLlLy0/Rv15C56bDoryj0vVkRYysU+waisK0etEskvE53JL0U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722535293; c=relaxed/simple; bh=B4USJ3DcoEtC2grgJaNeehMjrX/R6yyLoOz0nwuEw9c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l0k0OL8vfQ35wGGh1ihbntGpF+JYYIeCAH5o1H+I8wNYZ3Lg3BMLwFTzoQPULjNR70eO4hERXthg4Q+v7YVIKrSoKWVo0La/w0Aso2PpYMTD3R7sruTo6slGwHjPZCmix2Z2ouxfuyffU2XxM5SE4eIvozvg89pKv2wGRdOUAls= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GiWQMw0D; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GiWQMw0D" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7a23a0fb195so7397200a12.0 for ; Thu, 01 Aug 2024 11:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722535292; x=1723140092; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xl2Pju3NY9Fnm1xajnPNr4ZOFDET+sfv7XV8JXyIerc=; b=GiWQMw0D++CU3TjETx4tWGapTpULxvaI7JV6Y8bd9exHIvcVe2KloKaCc3sl+3L6Tr whnLzZIhzEez/vMO/EbpvHmq2wAgGJ4BG7oR6m6qaFWee2Z3VYCc2MgzVvBjWx0iICfw nZJ2uXfG1mZU5NCb98GEcsgaV5BQ1TqtHNsVSOT2VTUCyt4pZ1J7vd37da6yjBlA3a/L mU0Uxp+3lg8sOhDEfbThyyiskc0dco8Lp+UcfcgVENf11NBLbyPVCLIYm3d+74/+wk1+ szSkSkwBii8fJgyIYuhcHHQLyaXYegcbx8WIUKUe7Q1/CPGjkNJdQheQCVyL4TGy5rZS 6CPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722535292; x=1723140092; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xl2Pju3NY9Fnm1xajnPNr4ZOFDET+sfv7XV8JXyIerc=; b=pRjkbZRumGJZvxq28yl00MzXdP0+NVK6wOHJalmxjCbbO8OGK4Tc+dBnvTHnIftaaY nicvyo9JmGRGQkgXoTddt89FijAwv4LMCO0o9Nx8Z+wmd1m4T92/1F66A0t22r3KlA53 DMWi+zGI+Xwfy8LlwAof8wnJ4Y7Kxa3r++dz5effawj131HusF6E4t7hZahnvXl+qLhx MoPP2C0mPgoPM2ZRP+CqWVkxWtg38ILe/phH858hkxnjNZTPuF6EPGSK6wVtdaOfib++ 3uyD4yacnvbgAoXxNBINKw3oEP24OZulXRXIiWyveOVmiMVbR0cjOs2f62Fk0U57bQEj KmUw== X-Forwarded-Encrypted: i=1; AJvYcCUiIbkO2/mmvvLI2ZhUU4qRyMBedLio/eKcDwhuraymabzRUiau8n/Tcp1FCDYAOCmocwc7qf/Y17CEm1g11jNWTKNjiHB3riQVwkrP X-Gm-Message-State: AOJu0Yw4hfhb6lPBYGPT+/IeTVmkOSdH6TNEI7Ba6ahjVH/5daGwBWay 1CNDBF2QcHf7ONJw33AcINmipxk8Z5/2Jjb1tEoi/6MR5+L2rm1gQmTlBtdKmaZJDrqcgtMpcYE nCA== X-Google-Smtp-Source: AGHT+IF64U8Ib+bNIe3iPxoSzJOvvilQGXPjPZq7Y/8acNPwlcg0hACHnvmYPGnFv3dx9aufX4l27GJDySU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a65:6252:0:b0:75a:b299:85b6 with SMTP id 41be03b00d2f7-7b74669c7b3mr1534a12.2.1722535291408; Thu, 01 Aug 2024 11:01:31 -0700 (PDT) Date: Thu, 1 Aug 2024 11:01:30 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-3-seanjc@google.com> Message-ID: Subject: Re: [PATCH v12 02/84] KVM: arm64: Disallow copying MTE to guest memory while KVM is dirty logging From: Sean Christopherson To: "Aneesh Kumar K.V" Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , David Stevens Content-Type: text/plain; charset="us-ascii" On Thu, Aug 01, 2024, Aneesh Kumar K.V wrote: > Sean Christopherson writes: > > > Disallow copying MTE tags to guest memory while KVM is dirty logging, as > > writing guest memory without marking the gfn as dirty in the memslot could > > result in userspace failing to migrate the updated page. Ideally (maybe?), > > KVM would simply mark the gfn as dirty, but there is no vCPU to work with, > > and presumably the only use case for copy MTE tags _to_ the guest is when > > restoring state on the target. > > > > Fixes: f0376edb1ddc ("KVM: arm64: Add ioctl to fetch/store tags in a guest") > > Signed-off-by: Sean Christopherson > > --- > > arch/arm64/kvm/guest.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > > index e1f0ff08836a..962f985977c2 100644 > > --- a/arch/arm64/kvm/guest.c > > +++ b/arch/arm64/kvm/guest.c > > @@ -1045,6 +1045,11 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, > > > > mutex_lock(&kvm->slots_lock); > > > > + if (write && atomic_read(&kvm->nr_memslots_dirty_logging)) { > > + ret = -EBUSY; > > + goto out; > > + } > > + > > > > is this equivalent to kvm_follow_pfn() with kfp->pin = 1 ? No, gfn_to_pfn_prot() == FOLL_GET, kfp->pin == FOLL_PIN. But that's not really relevant. > Should all those pin request fail if kvm->nr_memslots_dirty_logging != 0? No, the conflict with dirty logging is specifically that this code doesn't invoke mark_page_dirty(). And it can't easily do that, because there's no loaded ("running") vCPU, i.e. doing so would trip this WARN: #ifdef CONFIG_HAVE_KVM_DIRTY_RING if (WARN_ON_ONCE(vcpu && vcpu->kvm != kvm)) return; WARN_ON_ONCE(!vcpu && !kvm_arch_allow_write_without_running_vcpu(kvm)); <==== #endif