Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1680123pxb; Thu, 4 Feb 2021 21:08:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSiT3Fs2PRAHPHFAkrIqoslQ7PF6mZv+fEbkhN2SrMr+q22uvmQQHLE1C2llXHnNS1IHDv X-Received: by 2002:a17:906:4e0c:: with SMTP id z12mr2374487eju.370.1612501737070; Thu, 04 Feb 2021 21:08:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612501737; cv=none; d=google.com; s=arc-20160816; b=1FrbgSyWQVid/kUHMPGLW8xvfZSNYrFi4BPWy8YhDsxO9DiYfbWJEfe2U3BL9KJvvL AjH7C8bIgjCQAGqq9zX3Xhnh2MdHJD07MyjRH9HVhYsxlaajwvrIikx61B5V2VQA721O D4XLk40oXrYFYOLOaBivPINItLiVWYvfjIFVqE02pGeALrchW40tut8tCtkRskCGW4i1 3zcgovwTSJ86OltUHeuj/B4ahCzp5pDI8drMA/Z2BAStsKL0msJU1P6tPFlYV4y7nUCV DjfQ3NStsyA9OBPi9Veu1okY8P00jruuSLs7aGyUmdKQ30oDtlKUneJkDvKPmD+L+1vd XQpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=2OHzmXgyp0y535q3b4QKEav8SvyEBNyjNLn+3PQBpgU=; b=Qt0OL5PMjTOtBAtb3WzJ1ivvV4jCuxqiyez7ZE87MZRNdxWrZz+p6INg24r7CbobiX mEnmOACsrEak0jCoQ0Q8/vKt/EWaxbIwuDoa/GiLIDfISmnhMXOO0Ih/gVWCRRpdgzfW wnP+WMYvbYqSwjecRL1KHq4/FYyNgpJs439SaTRyREtDdlKDTstHR96OQoGh49YKMAD0 S8MssvS7QAzAOIVKL5dxEx3E2315o7Ebb4Ma41cM2eQ3XGUzBaWdW+oIej7+aRFY8kJM 0gfFu+lPL8HFEvADLxZW4yGdqAzD+y0/qp1c6o/ULMDaimxnYh33/o+qG9y0Njs5D+R0 3yIA== ARC-Authentication-Results: i=1; mx.google.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 o27si4933926edz.400.2021.02.04.21.08.30; Thu, 04 Feb 2021 21:08:57 -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; 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 S230334AbhBEFHI convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Feb 2021 00:07:08 -0500 Received: from mail.kingsoft.com ([114.255.44.145]:9457 "EHLO mail.kingsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbhBEFHH (ORCPT ); Fri, 5 Feb 2021 00:07:07 -0500 X-AuditID: 0a580157-f21ff7000005df43-bc-601ccc9040ed Received: from mail.kingsoft.com (localhost [10.88.1.32]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.kingsoft.com (SMG-1-NODE-87) with SMTP id F6.84.57155.09CCC106; Fri, 5 Feb 2021 12:41:52 +0800 (HKT) Received: from alex-virtual-machine (172.16.253.254) by KSBJMAIL2.kingsoft.cn (10.88.1.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 5 Feb 2021 13:06:16 +0800 Date: Fri, 5 Feb 2021 13:06:16 +0800 From: Aili Yao To: "HORIGUCHI =?UTF-8?B?TkFPWUE=?=(=?UTF-8?B?5aCA5Y+j44CA55u05Lmf?=)" 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. Message-ID: <20210205130616.6d876846@alex-virtual-machine> In-Reply-To: <20210204072555.GA22850@hori.linux.bs1.fc.nec.co.jp> References: <20210201161749.0e8dc212.yaoaili@kingsoft.com> <20210204072555.GA22850@hori.linux.bs1.fc.nec.co.jp> Organization: kingsoft X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Originating-IP: [172.16.253.254] X-ClientProxiedBy: KSBJMAIL1.kingsoft.cn (10.88.1.31) To KSBJMAIL2.kingsoft.cn (10.88.1.32) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOIsWRmVeSWpSXmKPExsXCFcGooDvhjEyCwcqpbBafN/xjs3ixoZ3R YtpGcYvLu+awWdxb85/V4vyutawWlw4sYLK42HiA0eJ47wEmi82bpjJbvLlwj8Xix4bHrA48 Ht9b+1g8Nq/Q8li85yWTx6ZVnWwemz5NYvd4d+4cu8e8k4EeL65uZPF4v+8qm8fnTXIeJ1q+ sAZwR3HZpKTmZJalFunbJXBl3Nt5m7ngHX/Fn+nT2BsY9/F0MXJySAiYSJx8M4eli5GLQ0hg OpPE2h/LGCGcl4wSTfc2sINUsQioSLQcuMEGYrMJqErsujeLFcQWEUiSWDz7KxNIA7PADhaJ qxO/gBUJCyRLtJ5+ANbMK2Al0XSyAyzOKeAosX/zHLBmIYFCiS8zIYbyC4hJ9F75zwRxkr1E 25ZFjBC9ghInZz5hAbGZBTQlWrf/ZoewtSWWLXzNDDFHUeLwkl/sEL1KEke6Z7BB2LESy+a9 Yp3AKDwLyahZSEbNQjJqASPzKkaW4tx0w02MkLgL38E4r+mj3iFGJg7GQ4wSHMxKIryJbVIJ QrwpiZVVqUX58UWlOanFhxilOViUxHnFHPkShATSE0tSs1NTC1KLYLJMHJxSDUx1f5e3XuaZ LvPBtn5JwcpLXa5zL00RWp+z4WLUoqrutl9u6WxPYy/6G/4V94jjfal7//fm2g2J1n/8ldVU a6eLqH0Nc927/Vlq8P5JOtfLWfO8673ytSLY/tyqqAlRPzn5Psfmeavd7y0ozMqJyd3CWd3P P9O2qLJ44u3HDctyc/+oRRrcm9XWeXcjf13hl8dWdz9p2bjMitp+teaf0Kc9DVsP5C++sapp 3Zf21VduMLSopIXmTd1+JPFoiV7Hm6msRpZ+0m738lu4uVnWTDitlW21c93rFTsFHvYeypJL 2XAtdX+Rx9TjM56WGMrxcx84Jqn0NESgTu977jwl//VGBSJBxobs1gvm9HatOKnEUpyRaKjF XFScCABSn5XVKgMAAA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Feb 2021 07:25:55 +0000 HORIGUCHI NAOYA(堀口 直也) wrote: > 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. > > > > 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. > > > > Suggested-by: Feng Yang > > Signed-off-by: Aili Yao > > --- > ... > > > @@ -662,12 +662,32 @@ no_context(struct pt_regs *regs, unsigned long error_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 = 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 = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); > > + if (fault & VM_FAULT_HWPOISON) > > + lsb = PAGE_SHIFT; > > + > > + force_sig_mceerr(BUS_MCEERR_AR, (void __user *)address, lsb); > > This part contains some duplicated code with do_sigbus(), so some refactoring (like > adding a common function) would be more helpful. Yes, agree, I will modify this and rebase to the big fault series from tip. Thanks Aili Yao