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 X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAFD9C433B4 for ; Mon, 19 Apr 2021 20:32:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 48A7C61363 for ; Mon, 19 Apr 2021 20:32:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48A7C61363 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8E5196B0036; Mon, 19 Apr 2021 16:32:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B9FB6B006E; Mon, 19 Apr 2021 16:32:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 782906B0070; Mon, 19 Apr 2021 16:32:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id 5F55A6B0036 for ; Mon, 19 Apr 2021 16:32:47 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1E3085923C00 for ; Mon, 19 Apr 2021 20:32:47 +0000 (UTC) X-FDA: 78050265174.34.52AE28A Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) by imf18.hostedemail.com (Postfix) with ESMTP id 59A12200025C for ; Mon, 19 Apr 2021 20:32:48 +0000 (UTC) Received: by mail-vk1-f179.google.com with SMTP id u200so5263565vku.3 for ; Mon, 19 Apr 2021 13:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=hZIM+x23q0A7UAi2bLceHdWLfsqyYiEeL8Ivzgxf6vI=; b=bBeMgwnbZMMu0gE4mk9GFkiorCqXAKTvE45soY4o1fvNiBkfqj8H7aQ5SfEL77FQ7t nqXhsJpW0e/la0/iqsnbeeqOsVobBbzjQG9Kei7s2d+QJ/Au2nsJtFc6r6DBZp3NFzSV tw/Fztic2l0Ejp+/ArbfzmOIONJauF991A0EcnwbM/yB9S5e1bDTqtZYM1jts8OQLNWN qfiiYtsV4QrODCCrL4l1Az8ApDtYfNikE8rmhkiy24U8NN4o4UtRDFn+gkFO83pJFkkp VytK19MCX5Qo9SsqCdxV6KXpLti9mgp7wu5lKLRsMwvv88DESrXik2gLQk8iAMiHUMQK 7H1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=hZIM+x23q0A7UAi2bLceHdWLfsqyYiEeL8Ivzgxf6vI=; b=mkxx0LxyqAGjM1l9r5zKdG67CEislFDu51hyhe46pKfm23j/QZ82xPK38JO43jbn9d 57yK3aj1qMQtGH4RGQe4b8DMUeyj6qLrjNVyeOE81SsVui3BuKBBWHVY43tMCz4to5/U TGWeqcgq19GP7lOp6yuOu4bhk16qE4H4QAewrQddAC9SHuoiAA59OPYUNTq/jDpeDGPM 1MpeKkVBkZ6LEshpWksoLCUCGAyvdvb6Nkjk6hvWOYKcQS7KDcY3Ilr6InxaBdQFRGHF TlvVmHq6+wrBaeyrM0+8WcSZBlXWUhmexYvjy1o6mydANMcpjI+DpDKyr/cIIA2aMjWF 2yMg== X-Gm-Message-State: AOAM5328sPa+AgBZzEQqNUlnCslzFcTZgXpTikaCwedmqvLajAzvh9Lo V/TtoQOJYQYdlKzvp1rcrJiBj/a+87Lg/T60XOwJnw== X-Google-Smtp-Source: ABdhPJx5VwlGTJo82ed//GvPXquJ1foNXE2IGpGAdcHZpn2hmm+zqbcuHnIvIltGvbDg/Ju8ZOeLGMgVdqvinYCAEFk= X-Received: by 2002:ac5:c185:: with SMTP id z5mr16995254vkb.19.1618864365806; Mon, 19 Apr 2021 13:32:45 -0700 (PDT) MIME-Version: 1.0 From: Jue Wang Date: Mon, 19 Apr 2021 13:32:35 -0700 Message-ID: Subject: Re: [PATCH 3/4] mce/copyin: fix to not SIGBUS when copying from user hits poison To: "Luck, Tony" Cc: Borislav Petkov , linux-kernel@vger.kernel.org, linux-mm@kvack.org, luto@kernel.org, =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , x86 , yaoaili@kingsoft.com Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: sp5qpsy9pxathf7qea9i8zr3w4xzgmxt X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 59A12200025C Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf18; identity=mailfrom; envelope-from=""; helo=mail-vk1-f179.google.com; client-ip=209.85.221.179 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618864368-236403 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 8 Apr 2021 10:08:52 -0700, Tony Luck wrote: > KVM apparently passes a machine check into the guest. Though it seems > to be misisng the MCG_STATUS information to tell the guest whether this > is an "Action Required" machine check, or an "Action Optional" (i.e. > whether the poison was found synchonously by execution of the current > instruction, or asynchronously). The KVM_X86_SET_MCE ioctl takes a parameter of struct kvm_x86_mce, hypervisor can set with necessary semantics. 1140 #ifdef KVM_CAP_MCE 1141 /* x86 MCE */ 1142 struct kvm_x86_mce { 1143 __u64 status; 1144 __u64 addr; 1145 __u64 misc; 1146 __u64 mcg_status; 1147 __u8 bank; 1148 __u8 pad1[7]; 1149 __u64 pad2[3]; 1150 }; 1151 #endif > > Are we documenting somewhere: "if your process gets a SIGBUS and this > > and that, which means your page got offlined, you should do this and > > that to recover"? > Essentially it boils down to: > SIGBUS handler gets additional data giving virtual address that has gone away > 1) Can the application replace the lost page? > Use mmap(addr, MAP_FIXED, ...) to map a fresh page into the gap > and fill with replacement data. This case can return from SIGBUS > handler to re-execute failed instruction > 2) Can the application continue in degraded mode w/o the lost page? > Hunt down pointers to lost page and update structures to say > "this data lost". Use siglongjmp() to go to preset recovery path > 3) Can the application shut down gracefully? > Record details of the lost page. Inform next-of-kin. Exit. > 4) Default - just exit Two possible addition to these great points: 5) If for some reason the page cannot be unmapped (e.g., either losing to much memory like hugetlbfs 1G pages, or THP split failure for SHMEM THP), kernel maintains a consistent semantic (i.e., MCE SIGBUS with vaddr) to all future accesses from user space, by leaving the hwpoisoned page mapped or in the radix tree. 6). If for some reason the vaddr is not available upon the first MCE recovery and page is unmapped, kernel provides correct semantic (MCE SIGBUS with vaddr) in subsequent page faults from user space accessing the same vaddr.