Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DC0F2E738F for ; Wed, 17 Jun 2026 01:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781661160; cv=none; b=bVWtVkVTRd4GB4Kva2MEAboEB2iGajKeQpjv63Xx685P/l1HBUgDB/NBNGmU/AObZIvOUpdxYts72sMd4wm1h6i/HjtnIAB0zAtH+jeq69Sng+Skm+KDQk/xqHkqM2NLqvaCRqBFfLKuO7EBmCe5LshZiU6MQ523rjKPavxbpF4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781661160; c=relaxed/simple; bh=iEpECgFa1bNhzbGazUZJm4UryMfAcLUq23SZn/umUdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hsjY1eHUnS0ijlTrbkBrVGKdSNNOcGJ3GhpgJtAD5Q6wbPLZlZYhgW+twF2dCDf6fGxn1c4q1s324Rfrc2kEFzzxdgvOzTZNpDUIBpH0bJws6bwhhPSoZzMABnUwL/d3stLmGc84wPWzsBBbHFub7J8tvAJaFCnmnDh+UmuHZ/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=W6YqTLow; arc=none smtp.client-ip=115.124.30.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="W6YqTLow" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1781661150; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=R0h+j+S+bjkSjJl7zyJIJEUzxdG15FqSjgqTIvr+QaY=; b=W6YqTLowoop7xpGiHW3sZc9E9P1yIDUMZNQVT8Jrga/S+p8Wq7arF29KjC9awBs7iNifCGQapiYxDgBnAUsSJuSEy5KQQ9rD9qP7I0sEm7WTkS03ceqXauV65VH+pk0RNwPF0M4/I4jHvlrBAQuxjG3PlUWCxu5zMvu7HBQEfZE= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R691e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=tianruidong@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0X51LXEn_1781661148; Received: from localhost(mailfrom:tianruidong@linux.alibaba.com fp:SMTPD_---0X51LXEn_1781661148 cluster:ay36) by smtp.aliyun-inc.com; Wed, 17 Jun 2026 09:52:30 +0800 From: Ruidong Tian To: tony.luck@intel.com Cc: linux-kernel@vger.kernel.org, zhuo.song@linux.alibaba.com, oliver.yang@linux.alibaba.com, Ruidong Tian Subject: [PATCH 4/4] einj_mem_uc: add copy_mc_to_kernel() case Date: Wed, 17 Jun 2026 09:52:11 +0800 Message-ID: <20260617015211.3962419-5-tianruidong@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260617015211.3962419-1-tianruidong@linux.alibaba.com> References: <20260617015211.3962419-1-tianruidong@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ruidong Tian add a coredump case to test copy_mc_to_kernel, call stack as follow: [do_sea ] Fault PC (faulting insn): <__memcpy_mc> ffffb45742bee24c [do_sea ] Call stack: [do_sea ] [do_sea ] [do_sea ] [do_sea ] [do_sea ] [do_sea ] [extable ] Fault type: unknown(5) [extable ] Recovery addr (fixup): <__memcpy_mc> ffffb45742bee328 Signed-off-by: Ruidong Tian --- einj_mem_uc_mm.c | 51 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/einj_mem_uc_mm.c b/einj_mem_uc_mm.c index 3e23593..b495c22 100644 --- a/einj_mem_uc_mm.c +++ b/einj_mem_uc_mm.c @@ -2,12 +2,14 @@ /* * einj_mem_uc_mm.c - tests that exercise the kernel's MC-safe page - * copy primitives: copy_mc_user_highpage (COW / khugepaged / ksm) and - * copy_mc_highpage (page migration). + * copy primitives: copy_mc_user_highpage (COW / khugepaged / ksm), + * copy_mc_highpage (page migration) and copy_mc_to_kernel (the ELF core + * dumper's dump_page_copy()). * * Each test allocates a page in a way that lets the kernel reach one of * those primitives, and its trigger drives the operation synchronously - * whenever possible (MADV_COLLAPSE, move_pages, mbind MOVE, MADV_PAGEOUT). + * whenever possible (MADV_COLLAPSE, move_pages, mbind MOVE, MADV_PAGEOUT, + * or a core dump). */ #define _GNU_SOURCE 1 @@ -26,6 +28,8 @@ #include #include #include +#include +#include #include @@ -602,6 +606,45 @@ static int trigger_cow_anon_pinned(char *addr) } +/* ---------- core dump (copy_mc_to_kernel) ---------- */ + +/* + * trigger_coredump - exercise copy_mc_to_kernel() via the ELF core dumper. + */ +static int trigger_coredump(char *addr) +{ + pid_t pid; + + PRINT_TRIGGERING; + pid = fork(); + if (pid == 0) { + struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY }; + + child_process = 1; + /* Allow a core dump regardless of inherited limits. */ + setrlimit(RLIMIT_CORE, &rl); + prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); + /* + * Do NOT touch *addr ourselves: the poisoned page must be + * consumed by the kernel core dumper (dump_user_range -> + * dump_page_copy -> copy_mc_to_kernel), not by a user read. + */ + (void)addr; + abort(); /* SIGABRT -> core dump */ + _exit(0); /* not reached */ + } + if (pid > 0) { + int st; + + waitpid(pid, &st, 0); + if (WIFSIGNALED(st)) + printf("child killed by signal %d%s\n", WTERMSIG(st), + WCOREDUMP(st) ? " (core dumped)" : ""); + } + return 0; +} + + /* ---------- test table ---------- */ #define MM(name, help, alloc_fn, trig_fn, fl) \ @@ -631,6 +674,8 @@ struct test mm_tests[] = { MM("migrate_hugetlb", "move_pages(2) hugetlb file cross-node -> hugetlbfs_migrate_folio", mm_hugetlb_file_alloc, trigger_move_pages_hugetlb, F_MCE|F_CMCI|F_SIGBUS|F_FATAL), + MM("coredump", "Core dump of a poisoned page -> dump_page_copy -> copy_mc_to_kernel", + mm_anon_private_alloc, trigger_coredump, F_MCE|F_CMCI|F_FATAL), }; -- 2.39.3