From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09D9AC433FE for ; Fri, 7 Oct 2022 15:03:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D6DE6B0071; Fri, 7 Oct 2022 11:03:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75F036B0073; Fri, 7 Oct 2022 11:03:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B1DB6B0074; Fri, 7 Oct 2022 11:03:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 403E56B0071 for ; Fri, 7 Oct 2022 11:03:47 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0DF0EC1298 for ; Fri, 7 Oct 2022 15:03:47 +0000 (UTC) X-FDA: 79994472894.04.4AB06F5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id EB60340024 for ; Fri, 7 Oct 2022 15:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665155025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=G8ttGtE2a2pTgoA/DqN+azedYAoX3sBGph+P0+5Qq/M=; b=WDKng4SfpMwQctJO1joseSzf02e3hIWfQisCKzp3ivLH6Pg5kouzktGJJrgopqB3J4oI7y 69s5z4zzta+pkhmM1P6KD06xiRirTFFg7ZH7tEU3WrZNHplZvgiHbBym1yydqnmiUbcQKk DyFEUvqocOtD37RBwKGfeRjC327sI8k= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-467-NCy3pwXnMDija-xnP4Q7fA-1; Fri, 07 Oct 2022 11:03:44 -0400 X-MC-Unique: NCy3pwXnMDija-xnP4Q7fA-1 Received: by mail-qk1-f198.google.com with SMTP id h7-20020a05620a400700b006cebec84734so3979789qko.23 for ; Fri, 07 Oct 2022 08:03:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=G8ttGtE2a2pTgoA/DqN+azedYAoX3sBGph+P0+5Qq/M=; b=wFkSAl/RgmE4Kyr5ZK/2MwdSusHRQJE0XuqTeKgmTIfZGw6J6QPXJPC4B4Zsm8NreD gWihlUJqlXZan7x1BXXiNQKedvOv+xjU30sAo2qJo2GK2UAtj4pFj4k254KhqxIDKrtY DLUiYmdCCPmniasiCr9FfbLYx9Xvl3OWJ3lktagPXVrqpsuiWrl6CFrEjnWPq57+2mVd BXRnrHBCjAzKnRzydBplrX0FIAZPeVX/hG0WUFzqUUbXTagCVGseVU1XyYfpxkUP6GLp 9rnLswPPdn7dkKD10QKl1zmdcv7zDFskeu51FFBJE5kHBAlLmEXCJXqIOSW4JQy+qfsx Jx1A== X-Gm-Message-State: ACrzQf1C7KmIy1VnhifLyP/fLZeV9anA9x6gQhUz7ukmTDUGbPEH8/g6 pc7Zot2noQdm1WMl03FRkFk7376gGvfgLcxbthxH0dU3whjqe5GO1O5Xtl30fPgHhRFv1ZYQGLv twAXr95JlgG4= X-Received: by 2002:a05:622a:5cb:b0:394:8a8c:7063 with SMTP id d11-20020a05622a05cb00b003948a8c7063mr4558078qtb.330.1665155023529; Fri, 07 Oct 2022 08:03:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6rKdQz36a0mgxBntg7slDBs/JqYYsZlFJrYaDVhGwd+e+Z7Fl4Xv1Pf4YaXvUgtvGqcQ2Dsg== X-Received: by 2002:a05:622a:5cb:b0:394:8a8c:7063 with SMTP id d11-20020a05622a05cb00b003948a8c7063mr4558054qtb.330.1665155023292; Fri, 07 Oct 2022 08:03:43 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id v1-20020a05620a0f0100b006bb8b5b79efsm2339333qkl.129.2022.10.07.08.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 08:03:42 -0700 (PDT) Date: Fri, 7 Oct 2022 11:03:41 -0400 From: Peter Xu To: Sean Christopherson Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, David Hildenbrand , Andrew Morton , Andrea Arcangeli , Paolo Bonzini , "Dr . David Alan Gilbert" , Linux MM Mailing List , John Hubbard Subject: Re: [PATCH v3 2/3] kvm: Add new pfn error KVM_PFN_ERR_SIGPENDING Message-ID: References: <20220817003614.58900-1-peterx@redhat.com> <20220817003614.58900-3-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665155026; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=G8ttGtE2a2pTgoA/DqN+azedYAoX3sBGph+P0+5Qq/M=; b=wVsouctJwY7nCm3M1cR1xSVFMNjmwHuV6v52DGuUqdzaEGqnmQQFKQWDJJfVxt3mJlq556 n/2WAsELCPjLWQ4fUvoL0+w1i6XKCHGjVCwCP1G2IdRnOwfclfCD9MJRQzNqKcvCHUubFR jiQZctbezCXAly25+31mUTcn4Hn2FcI= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WDKng4Sf; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665155026; a=rsa-sha256; cv=none; b=vNdUYs0nVTiRppP65pj0qAAd/fC2D1gpavoUKkNYn4OA0fsp+AiODHb1d8eulPCunOMwh4 68SOxc2wFlKmy6gdBvpU5NS0Viykf2/R10kYIT2NyQCj2bWcrmlvpfDzsOnw/1wrhCCbHY pH2D3UvW08/+VxhbffNtBA23uJOu6Hw= X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: EB60340024 X-Stat-Signature: 7k69d974sh45apciuc5p3ti1ke9999ur Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WDKng4Sf; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1665155025-396364 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 07, 2022 at 01:39:17AM +0000, Sean Christopherson wrote: > On Tue, Aug 16, 2022, Peter Xu wrote: > > Since at it, renaming kvm_handle_bad_page to kvm_handle_error_pfn assuming > > Please put parantheses after function names, e.g. kvm_handle_bad_page(). > > > that'll match better with what it does, e.g. KVM_PFN_ERR_SIGPENDING is not > > accurately a bad page but just one kind of errors. > > ... > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > index 3e1317325e1f..23dc46da2f18 100644 > > --- a/arch/x86/kvm/mmu/mmu.c > > +++ b/arch/x86/kvm/mmu/mmu.c > > @@ -3134,8 +3134,13 @@ static void kvm_send_hwpoison_signal(unsigned long address, struct task_struct * > > send_sig_mceerr(BUS_MCEERR_AR, (void __user *)address, PAGE_SHIFT, tsk); > > } > > > > -static int kvm_handle_bad_page(struct kvm_vcpu *vcpu, gfn_t gfn, kvm_pfn_t pfn) > > +static int kvm_handle_error_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, kvm_pfn_t pfn) > > { > > + if (is_sigpending_pfn(pfn)) { > > + kvm_handle_signal_exit(vcpu); > > + return -EINTR; > > + } > > ... > > > @@ -2648,9 +2651,12 @@ kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async, > > if (atomic) > > return KVM_PFN_ERR_FAULT; > > > > - npages = hva_to_pfn_slow(addr, async, write_fault, writable, &pfn); > > + npages = hva_to_pfn_slow(addr, async, write_fault, interruptible, > > + writable, &pfn); > > if (npages == 1) > > return pfn; > > + if (npages == -EINTR) > > + return KVM_PFN_ERR_SIGPENDING; > > This patch should be split into 3 parts: > > 1. Add KVM_PFN_ERR_SIGPENDING and the above code > 2. Add the interruptible flag > 3. Add handling in x86 and rename kvm_handle_bad_page() > > With #3 merged with patch 3. > > That was if there's oddball arch code that reacts poorly to KVM_PFN_ERR_SIGPENDING, > those errors will bisect to #1. > > And if there's a typo in the plumbing, that bisects to #2. > > And if something goes sideways in x86, those bugs bisect to #3 (patch 3), and it's > easy to revert just the x86 changes (though I can't imagine that's likely). Yeah the x86 change in this patch is indeed a bit weird with the generic subject. All points taken, thanks. -- Peter Xu