From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (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 9595E43CE60 for ; Tue, 4 Aug 2026 21:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785877738; cv=none; b=AP8h0o+9c1ESa+wcMg5EXb7ETZJkQ7ZdEUnRxypDZSvUp8Q2G9dB4Z8JgEHVllXTroYbA8XQyJuB0SxEQq8IVsEeG+lMtDTNqyWmDZebgj25tT5smcnxz4C+lqg/hIsdaP67A19mtbfUNjCR+opTZ96jshCogUFOemEwoAZDNLw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785877738; c=relaxed/simple; bh=B43iZ28kyQuj/oVdK+ysKMvEqAmzWYTHNTxAOsjpuPs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=p/fEcdiVJnXBJ6qF/DnOaW+4xiL8p1tP0H9ZS0/O9+I5aSVLZP1AVTgIuZGqO6Ti8BG5YUDjucnm4ItIc0NNSHS9l6wp/jMcfnFKkHdhQcz4x09wojjHYbjG8ZVaeeO8bGDx7fC4VR5XrFFdWYRnHMxljemezjVvBeLalNpKAr8= 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=SG3g0pGI; arc=none smtp.client-ip=209.85.216.69 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="SG3g0pGI" Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3823dcc1647so291295a91.3 for ; Tue, 04 Aug 2026 14:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785877736; x=1786482536; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Nz3aCp4Uyw3qY+MX7Sv/bu2ByRkx6w/quCe3kJ8ANw0=; b=SG3g0pGIoyAD64YwDxeDpGN+p/yg/zWH8SnKSHba5X4kfDWsRJQ+uK3ZI596ljPxYW qDRG03x6tomX3jpXAfi1tiMeg8HfIxw07nnoWU71596tAGKTlr5w76QP8uz+7xQcTNzu HRYTNpilusueBIVwsjoP3vGN5twZCHZc/8nfKgokeQfP8BcRj0Q60Nem1s3e4Wym/mi5 XqDzcuJw59lHT1KpP1z7lplDF50dJu6aOpnieUQRjset65b4RrEk5uKocTFFSYIAJYBB Bq/ztFWzIuR6fo2/xAf5OA92omhyCrCTknRwpLehSmQOp0Kzw7k/i+zQbRffPrNMevj5 4x1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785877736; x=1786482536; h=content-type: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:content-type; bh=Nz3aCp4Uyw3qY+MX7Sv/bu2ByRkx6w/quCe3kJ8ANw0=; b=qJ8T2xgw/rsZHJehN4qSoAsXwgiU6LzR61Corz2sFk8gDh6pOT2dSdKPiSrgpYWm59 xJxxVXDgfgYRW3AxwWTJjFJuFPewg3X3WE1uofCTmySMFZLIhD6TApAnjXSbvsBHTwxn QHHkI1CMZax5aoASZFSpHCO/yTKTBUQ7F/FwFdyYyjqEew204yY0472Ap5f16qLd/mBM AQVhuv6Rhy1n9YvQgmZWLwb2fyDzOJy5vIzNaS2T4oJ607lLiTkWPPsCOk/p5R7/Yy3C btbDHlTr3HQcQcvOzhgzrhyN5ebZ674PnmYeMXS2k6HzxrzX2R1igeIex8j+Ei0Ylsr+ m39A== X-Gm-Message-State: AOJu0YyL6f25H/tThGJ2SgRwOdCYXNYM1KUy28RSK2GOSUVCu54zbA0Q 0z352yMzIOeXjRJgkoeZyJBgg2Sq6RPSJIOMJbULp0V4yM9kU9QjuoiyPI/85fEfhxWdR2ifFG/ bWSaX9w== X-Received: from pjsa12.prod.google.com ([2002:a17:90a:be0c:b0:38f:e6f2:5944]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:d644:b0:38e:2860:253f with SMTP id 98e67ed59e1d1-3903c582511mr1841710a91.12.1785877735649; Tue, 04 Aug 2026 14:08:55 -0700 (PDT) Date: Tue, 4 Aug 2026 14:08:55 -0700 In-Reply-To: <20260804120529.1730187-7-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260804120529.1730187-1-pbonzini@redhat.com> <20260804120529.1730187-7-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH v2 6/6] kvm: return -EFAULT for writes to !VM_WRITE IO mappings From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Alex Williamson , bcm-kernel-feedback-list@broadcom.com, Boris Brezillon , Christian Koenig , David Hildenbrand , dri-devel@lists.freedesktop.org, Fei Li , Huang Rui , linux-mm@kvack.org, linux-s390@vger.kernel.org, Michal Hocko , Peter Xu , Sergio Lopez , Thomas Zimmermann Content-Type: text/plain; charset="us-ascii" I strongly prefer "KVM:" for the scope, and it's waaay more common. $ git log --pretty=oneline --after 2015.01.01 | grep "kvm:" | wc -l 1298 $ git log --pretty=oneline --after 2015.01.01 | grep "KVM:" | wc -l 16249 On Tue, Aug 04, 2026, Paolo Bonzini wrote: > KVM's behavior when the guest writes to a non-writable VMA is inconsistent. > For regular, page-backed mappings it returns KVM_PFN_ERR_FAULT and thus > returns -EFAULT to userspace (which is ABI, and relied upon by tests); > for VM_IO/VM_PFNMAP mappings instead it returns KVM_PFN_ERR_RO_FAULT > and thus exits to userspace with KVM_EXIT_MMIO. > > This behavior for VM_{IO,PFNMAP} was added by commit bd2fae8da794 ("KVM: > do not assume PTE is writable after follow_pfn"), and even if it has been > in place for five years it is unlikely that it is relied upon by userspace, > since it is inconsistent with KVM itself. Change hva_to_pfn() to return > KVM_PFN_ERR_FAULT for all non-writable VMAs, and restrict KVM_EXIT_MMIO > to the case of an explicitly read-only memslot. > > Suggested-by: Sean Christopherson > Signed-off-by: Paolo Bonzini > --- Shortlog nit aside, Reviewed-by: Sean Christopherson