blob: 3e80d28b68d9e1150626fc23277893f118dbfb12 [file] [log] [blame] [edit]
/*
* AMD SEV test cases
*
* Copyright (c) 2021, Google Inc
*
* Authors:
* Hyunwook (Wooky) Baek <baekhw@google.com>
* Zixuan Wang <zixuanwang@google.com>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "libcflat.h"
#include "x86/processor.h"
#include "x86/amd_sev.h"
#include "msr.h"
#define TESTDEV_IO_PORT 0xe0
static char st1[] = "abcdefghijklmnop";
static void test_stringio(void)
{
int st1_len = sizeof(st1) - 1;
u16 got;
asm volatile("cld \n\t"
"movw %0, %%dx \n\t"
"rep outsw \n\t"
: : "i"((short)TESTDEV_IO_PORT),
"S"(st1), "c"(st1_len / 2));
asm volatile("inw %1, %0\n\t" : "=a"(got) : "i"((short)TESTDEV_IO_PORT));
report((got & 0xff) == st1[sizeof(st1) - 3], "outsb nearly up");
report((got & 0xff00) >> 8 == st1[sizeof(st1) - 2], "outsb up");
}
int main(void)
{
if (!amd_sev_enabled()) {
report_skip("AMD SEV not enabled\n");
goto out;
}
printf("SEV-ES is %senabled.\n", amd_sev_es_enabled() ? "" : "not ");
test_stringio();
out:
return report_summary();
}