Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp907869pxb; Wed, 3 Feb 2021 23:33:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUOqqjX7B/IDw5tKgwMh60Wky9IhtEJkeGw748Jq/0HJE7wZ9yRgWYC/tBxxGj4KOJdw8O X-Received: by 2002:aa7:d489:: with SMTP id b9mr6776972edr.374.1612424008213; Wed, 03 Feb 2021 23:33:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1612424008; cv=pass; d=google.com; s=arc-20160816; b=cyXr1TL7La27ZYCFIpMnNF78yhFTh4I80YxYYJc0epvsxTGm6zdTs1MKrWQhfvrRei J6fyRKVsnUW19xIxlJfU3FPERcd84KlM3JsU/hCS120fWXTJwcNDAGjc6qaJM8ZlrU5Y YrQ5SU2Tehea6Y8xHg59dhz85SpYnxpe1H/ltLCB2w8PNr2dxKlWKnxx0R8yClKYba/9 z5uVZrAKYIYwEuCAvJw3vHWbYIvX7GHOSdqBr1HL3Dq2TDmP6I4wtZCRweWULu1dWWcE TYGBSmRviXrX1KZ6lUyvX5RVqnMQKAX8NDPuWbubSam1S1M3QLDko/2LHdWz3ygmX5hY 1REQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=LecriwBT6qVbIG6TCnIvu4moI89380w82UiWCLljcuc=; b=siqMGH3W2Y+xtq5xx8Kup5ydZXYcfTNzIDVpCdySfHnOmczFVDk81Uwe7k1KQVtVLH J94V+Ow/QzZ/nN8HfccN0xNOvrOMxQ4nr7geg89/KaMvqcMV1gr3OO4F0btQKphNqVpq iMpHuw9C2HA/VTqOxjwLTjOCIdvKD9DIV7JGjUMDvsrig9hV+UmGlAYYGW5LnE7gmwqv /5JOcT4QjlqtLeGJotdU9Way8Lb73CcRFLjcOHAZ4ItX3y4is+cKtv8g8iOa1ZzYwbaD HFeJl6Am/S8/SIpmd1l5EqIFvya09bxkxkJc9MLhzS1Cbie9BxyZeezjn4VstZzGHGur F69g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nec.com header.s=selector1 header.b=PsHWFaHM; arc=pass (i=1 spf=pass spfdomain=nec.com dkim=pass dkdomain=nec.com dmarc=pass fromdomain=nec.com); 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw9si2735074ejb.734.2021.02.03.23.33.03; Wed, 03 Feb 2021 23:33:28 -0800 (PST) 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=@nec.com header.s=selector1 header.b=PsHWFaHM; arc=pass (i=1 spf=pass spfdomain=nec.com dkim=pass dkdomain=nec.com dmarc=pass fromdomain=nec.com); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234571AbhBDH2a (ORCPT + 99 others); Thu, 4 Feb 2021 02:28:30 -0500 Received: from mail-eopbgr1400081.outbound.protection.outlook.com ([40.107.140.81]:36352 "EHLO JPN01-TY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234509AbhBDH2Q (ORCPT ); Thu, 4 Feb 2021 02:28:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hhVerna67aQNu2cYN1kwaBr0Lsg5Ufnhml1BP43AgzemAtLgdmdgZd7cnGFQd2CbpsZi6TNQgVFtol13oeacyJmGK9mU3x7JxQdfFX57D+bD9/RzRmb3fs2prB412W9cHLDDliCjlhmr+n/YOE4cMn8bGTCHGoKDPM0qoszYB5+EJ7ZW275PL+lfPHMqkFc0lyfthvQrjRKkE2NiWO1TRLe7mLF4fBCfNSnH2V6LkMNQMLqpgk0BXCm7MzP5/qXLUXvTm9XYbN8KrqAVc5bSRUiIsOwa/G65o6VvbeGAs/nhK6gFcbI0NMk6BSBameGCAbjoVCV9l8RcWa1jDpbcFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LecriwBT6qVbIG6TCnIvu4moI89380w82UiWCLljcuc=; b=fpKu571EJndH6Mm6oVMSuxNYNHxlHpWQi5gb1MhU8HXKLHT9fM2834Kw3cNQGLtTPqq/aNT1hsfarPeYU2zHmY16tpcrur4xmZKe2hwERCT0rWUCYRH/393/4PPyioqV1t6E9901rmXyHND0SMSuee3WO6G8p/FhDJGLPRNKHU1Vv7GNpSUh6QzfZGgngpJBVhOPesYQ2Atz0LXFQvV3VLHnheORebC/VyGiIpetxlIte/aSBrUAdKegH6UBoI3Wct5UdVev4g6Wc09MoBUQYmW6we1sVfPS+aZ8iMLSSqC6FLVGU0jCtMyrlQwmRb7jIV2y/K19mLffekrF+iOGDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nec.com; dmarc=pass action=none header.from=nec.com; dkim=pass header.d=nec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nec.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LecriwBT6qVbIG6TCnIvu4moI89380w82UiWCLljcuc=; b=PsHWFaHM+abM/Uq3qoZgP3xt5Es8dP9SGryJxcD0ydDSqaGhvMbDvKmV1vSwukrOatEju5plAFOGRXuIa2mkEySm2Yd1EzifuZPqf0af2NYLgw++6+iB6CMw+/NfVZDxoJgUmaDMBn6JpUBkDrlXeGXx1LeAx+b6A9l9GXQyByI= Received: from TY1PR01MB1852.jpnprd01.prod.outlook.com (2603:1096:403:8::12) by TYBPR01MB5344.jpnprd01.prod.outlook.com (2603:1096:404:802f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19; Thu, 4 Feb 2021 07:25:58 +0000 Received: from TY1PR01MB1852.jpnprd01.prod.outlook.com ([fe80::1d15:6a82:ea9b:5101]) by TY1PR01MB1852.jpnprd01.prod.outlook.com ([fe80::1d15:6a82:ea9b:5101%6]) with mapi id 15.20.3805.024; Thu, 4 Feb 2021 07:25:58 +0000 From: =?iso-2022-jp?B?SE9SSUdVQ0hJIE5BT1lBKBskQktZOH0hIUQ+TGkbKEIp?= To: Aili Yao CC: "tony.luck@intel.com" , "dave.hansen@linux.intel.com" , "luto@kernel.org" , "peterz@infradead.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" , "x86@kernel.org" , "YANGFENG1@kingsoft.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] x86/fault: Send a SIGBUS to user process always for hwpoison page access. Thread-Topic: [PATCH v2] x86/fault: Send a SIGBUS to user process always for hwpoison page access. Thread-Index: AQHW+HLnmNDQRaoKqkifESD/mJ9TwKpHnQ2A Date: Thu, 4 Feb 2021 07:25:55 +0000 Message-ID: <20210204072555.GA22850@hori.linux.bs1.fc.nec.co.jp> References: <20210201161749.0e8dc212.yaoaili@kingsoft.com> In-Reply-To: <20210201161749.0e8dc212.yaoaili@kingsoft.com> Accept-Language: ja-JP, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: kingsoft.com; dkim=none (message not signed) header.d=none;kingsoft.com; dmarc=none action=none header.from=nec.com; x-originating-ip: [165.225.110.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7408a35a-b6ee-4551-af41-08d8c8de1dbf x-ms-traffictypediagnostic: TYBPR01MB5344: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TDTPgPleo77NmYzAkyb1+sOrORr9a7Zy1Vdd6WdGTpqEVB4jhBrApoLrz/bv6CReQGVksLIGz8MHZxXXdnn/cKqZ1zvtUi3VVhK43wxN4wU7az3cOswQ24w3JELjIOevumIXkgD/qLtrihJ462GR+oLGBzUK94ZRj3EncvvrG4uNEnzinmmajc5zKrZXIyEfNQqDFqX9JtA/1AksGvCibamvgz5iPu0j9kmW0LB5mfF9FPOP5BiqKsoc1YyhdI5PCo8B1njjBC9gadS1gxS7TOZ5W4oH69GRyDyGBXNo344EfquwBOtO5Y870OwxwktGEiDcar7LbdsbGGO8Mwf0jiBvyXJBhRsXeBZstn39RWjop9sE8RZKGKciicrgohXNFgWCxPWUORP1HkDxVBqQFShAMX4nsFklH57HMq6j8OtvVFFHElr9ZqpfmnG99E3A57jaD6KgwXHQyBlHGXZH/pViLyZY1gjOOwhXO7qfsp2/S5TnbAL3sdqQhBi/EK8Xt6w1ZUgy8U2/uNO8xc1VNQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY1PR01MB1852.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(366004)(376002)(39860400002)(346002)(136003)(478600001)(6916009)(4326008)(85182001)(76116006)(54906003)(316002)(66556008)(83380400001)(66446008)(64756008)(66476007)(186003)(66946007)(8936002)(7416002)(26005)(55236004)(8676002)(71200400001)(86362001)(33656002)(6506007)(5660300002)(9686003)(6512007)(6666004)(1076003)(2906002)(6486002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-2022-jp?B?SCtlNXRIUXdOb01POW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htQnVoTlVVMlk4Y2F2WDQ4UE0rVUNBTVpqdG9mQlVXUGJn?= =?iso-2022-jp?B?NEdmUTBXTEJwckNPc0dJTzVlbUJHM3FzU1BVRnRaYWFiMzg1T0JQMGdL?= =?iso-2022-jp?B?OVdNRWR4ZEJYWkVBbVlqOHJWd3V6N0w0eVJwME1vTnlya0NMWEhrSlZP?= =?iso-2022-jp?B?WVpxUGlTeVVjTFFLbFdjc1hsNnlTQzQ0QlhaanZ1VmJoL0d2Qk01SkNu?= =?iso-2022-jp?B?cFppWXRCOVpWTmhnUE1EYlVXa0J6a0k1c0dHZ3lCb3NTWlFLZTJxQVkx?= =?iso-2022-jp?B?SWM5dm14MEhUS0tiU2huVHpTTWczdHcydkpvZUc3R0NiOEtodjR1MGtX?= =?iso-2022-jp?B?ZTBQMk5raTdwekRpakdwUm5IR0dxWkw0eDFUYTNTcjIzcWdSaVVQVFE4?= =?iso-2022-jp?B?bzlHalpaTkJJK29WTWNFRUNDR0U1ajZkdmQrc3duSXpaRG4zWUMvQ0Er?= =?iso-2022-jp?B?WmJZNzhwbTRBb1BaK1RrUEZPVkVmWHR4MjE3NlBtckFsY1JaSU9IWnR2?= =?iso-2022-jp?B?VmVHQmdabkRsZ3JEL2xjaHBNWHlINUFQWWhQNFowTnd4MXRVcTd0U3l4?= =?iso-2022-jp?B?b0VTa2gvVjE5azZVNFAyVmxWa1Awcjg1UW5heHBVRGFWTFB5RjVQWko4?= =?iso-2022-jp?B?SnJaaWE5TkV4c0xtSFNDL3pBPT0=?= Content-Type: text/plain; charset="iso-2022-jp" Content-ID: <5290B686DEA80A40B885E2B307137BFE@jpnprd01.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nec.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TY1PR01MB1852.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7408a35a-b6ee-4551-af41-08d8c8de1dbf X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Feb 2021 07:25:57.8702 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: e67df547-9d0d-4f4d-9161-51c6ed1f7d11 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7qZlC2HaA1iYnwJUU+j64eJbTuvN56/hejJeCxkkk/sD0e5A110eKBoPGV4sqfCdwM3NvqyfwTN+EWoAGXuLfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYBPR01MB5344 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Aili, On Mon, Feb 01, 2021 at 04:17:49PM +0800, Aili Yao wrote: > When one page is already hwpoisoned by AO action, process may not be > killed, the process mapping this page may make a syscall include this > page and result to trigger a VM_FAULT_HWPOISON fault, if it's in kernel > mode it may be fixed by fixup_exception. Current code will just return > error code to user process. >=20 > This is not sufficient, we should send a SIGBUS to the process and log > the info to console, as we can't trust the process will handle the error > correctly. >=20 > Suggested-by: Feng Yang > Signed-off-by: Aili Yao > --- ... > @@ -662,12 +662,32 @@ no_context(struct pt_regs *regs, unsigned long erro= r_code, > * In this case we need to make sure we're not recursively > * faulting through the emulate_vsyscall() logic. > */ > + > + if (IS_ENABLED(CONFIG_MEMORY_FAILURE) && > + fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { > + unsigned int lsb =3D 0; > + > + pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at= %lx\n", > + current->comm, current->pid, address); > + > + sanitize_error_code(address, &error_code); > + set_signal_archinfo(address, error_code); > + > + if (fault & VM_FAULT_HWPOISON_LARGE) > + lsb =3D hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); > + if (fault & VM_FAULT_HWPOISON) > + lsb =3D PAGE_SHIFT; > + > + force_sig_mceerr(BUS_MCEERR_AR, (void __user *)address, lsb); This part contains some duplicated code with do_sigbus(), so some refactori= ng (like adding a common function) would be more helpful. Thanks, Naoya Horiguchi=