Skip to content

Commit

Permalink
x86, libnvdimm/test: Remove COPY_MC_TEST
Browse files Browse the repository at this point in the history
The COPY_MC_TEST facility has served its purpose for validating the
early termination conditions of the copy_mc_fragile() implementation.
Remove it and the EXPORT_SYMBOL_GPL of copy_mc_fragile().

Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/160316688322.3374697.8648308115165836243.stgit@dwillia2-desk3.amr.corp.intel.com
  • Loading branch information
Dan Williams authored and Borislav Petkov committed Oct 26, 2020
1 parent 8d71d2b commit 3adb776
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 195 deletions.
3 changes: 0 additions & 3 deletions arch/x86/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ config EARLY_PRINTK_USB_XDBC
You should normally say N here, unless you want to debug early
crashes or need a very simple printk logging facility.

config COPY_MC_TEST
def_bool n

config EFI_PGT_DUMP
bool "Dump the EFI pagetable"
depends on EFI
Expand Down
75 changes: 0 additions & 75 deletions arch/x86/include/asm/copy_mc_test.h

This file was deleted.

4 changes: 0 additions & 4 deletions arch/x86/lib/copy_mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#include <asm/mce.h>

#ifdef CONFIG_X86_MCE
/*
* See COPY_MC_TEST for self-test of the copy_mc_fragile()
* implementation.
*/
static DEFINE_STATIC_KEY_FALSE(copy_mc_fragile_key);

void enable_copy_mc_fragile(void)
Expand Down
10 changes: 0 additions & 10 deletions arch/x86/lib/copy_mc_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
/* Copyright(c) 2016-2020 Intel Corporation. All rights reserved. */

#include <linux/linkage.h>
#include <asm/copy_mc_test.h>
#include <asm/export.h>
#include <asm/asm.h>

#ifndef CONFIG_UML

#ifdef CONFIG_X86_MCE
COPY_MC_TEST_CTL

/*
* copy_mc_fragile - copy memory with indication if an exception / fault happened
Expand Down Expand Up @@ -38,8 +35,6 @@ SYM_FUNC_START(copy_mc_fragile)
subl %ecx, %edx
.L_read_leading_bytes:
movb (%rsi), %al
COPY_MC_TEST_SRC %rsi 1 .E_leading_bytes
COPY_MC_TEST_DST %rdi 1 .E_leading_bytes
.L_write_leading_bytes:
movb %al, (%rdi)
incq %rsi
Expand All @@ -55,8 +50,6 @@ SYM_FUNC_START(copy_mc_fragile)

.L_read_words:
movq (%rsi), %r8
COPY_MC_TEST_SRC %rsi 8 .E_read_words
COPY_MC_TEST_DST %rdi 8 .E_write_words
.L_write_words:
movq %r8, (%rdi)
addq $8, %rsi
Expand All @@ -73,8 +66,6 @@ SYM_FUNC_START(copy_mc_fragile)
movl %edx, %ecx
.L_read_trailing_bytes:
movb (%rsi), %al
COPY_MC_TEST_SRC %rsi 1 .E_trailing_bytes
COPY_MC_TEST_DST %rdi 1 .E_trailing_bytes
.L_write_trailing_bytes:
movb %al, (%rdi)
incq %rsi
Expand All @@ -88,7 +79,6 @@ SYM_FUNC_START(copy_mc_fragile)
.L_done:
ret
SYM_FUNC_END(copy_mc_fragile)
EXPORT_SYMBOL_GPL(copy_mc_fragile)

.section .fixup, "ax"
/*
Expand Down
103 changes: 0 additions & 103 deletions tools/testing/nvdimm/test/nfit.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "nfit_test.h"
#include "../watermark.h"

#include <asm/copy_mc_test.h>
#include <asm/mce.h>

/*
Expand Down Expand Up @@ -3284,107 +3283,6 @@ static struct platform_driver nfit_test_driver = {
.id_table = nfit_test_id,
};

static char copy_mc_buf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));

enum INJECT {
INJECT_NONE,
INJECT_SRC,
INJECT_DST,
};

static void copy_mc_test_init(char *dst, char *src, size_t size)
{
size_t i;

memset(dst, 0xff, size);
for (i = 0; i < size; i++)
src[i] = (char) i;
}

static bool copy_mc_test_validate(unsigned char *dst, unsigned char *src,
size_t size, unsigned long rem)
{
size_t i;

for (i = 0; i < size - rem; i++)
if (dst[i] != (unsigned char) i) {
pr_info_once("%s:%d: offset: %zd got: %#x expect: %#x\n",
__func__, __LINE__, i, dst[i],
(unsigned char) i);
return false;
}
for (i = size - rem; i < size; i++)
if (dst[i] != 0xffU) {
pr_info_once("%s:%d: offset: %zd got: %#x expect: 0xff\n",
__func__, __LINE__, i, dst[i]);
return false;
}
return true;
}

void copy_mc_test(void)
{
char *inject_desc[] = { "none", "source", "destination" };
enum INJECT inj;

if (IS_ENABLED(CONFIG_COPY_MC_TEST)) {
pr_info("%s: run...\n", __func__);
} else {
pr_info("%s: disabled, skip.\n", __func__);
return;
}

for (inj = INJECT_NONE; inj <= INJECT_DST; inj++) {
int i;

pr_info("%s: inject: %s\n", __func__, inject_desc[inj]);
for (i = 0; i < 512; i++) {
unsigned long expect, rem;
void *src, *dst;
bool valid;

switch (inj) {
case INJECT_NONE:
copy_mc_inject_src(NULL);
copy_mc_inject_dst(NULL);
dst = &copy_mc_buf[2048];
src = &copy_mc_buf[1024 - i];
expect = 0;
break;
case INJECT_SRC:
copy_mc_inject_src(&copy_mc_buf[1024]);
copy_mc_inject_dst(NULL);
dst = &copy_mc_buf[2048];
src = &copy_mc_buf[1024 - i];
expect = 512 - i;
break;
case INJECT_DST:
copy_mc_inject_src(NULL);
copy_mc_inject_dst(&copy_mc_buf[2048]);
dst = &copy_mc_buf[2048 - i];
src = &copy_mc_buf[1024];
expect = 512 - i;
break;
}

copy_mc_test_init(dst, src, 512);
rem = copy_mc_fragile(dst, src, 512);
valid = copy_mc_test_validate(dst, src, 512, expect);
if (rem == expect && valid)
continue;
pr_info("%s: copy(%#lx, %#lx, %d) off: %d rem: %ld %s expect: %ld\n",
__func__,
((unsigned long) dst) & ~PAGE_MASK,
((unsigned long ) src) & ~PAGE_MASK,
512, i, rem, valid ? "valid" : "bad",
expect);
}
}

copy_mc_inject_src(NULL);
copy_mc_inject_dst(NULL);
}

static __init int nfit_test_init(void)
{
int rc, i;
Expand All @@ -3393,7 +3291,6 @@ static __init int nfit_test_init(void)
libnvdimm_test();
acpi_nfit_test();
device_dax_test();
copy_mc_test();
dax_pmem_test();
dax_pmem_core_test();
#ifdef CONFIG_DEV_DAX_PMEM_COMPAT
Expand Down

0 comments on commit 3adb776

Please sign in to comment.