-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[guest-test] New Test: add TDX #VE HALT handling TC
add TDX #VE HALT handling TC based on tdx_halt_test_module [Test Components] tdx [Test Types] func [Supported Devices] spr,emr,gnr,srf Signed-off-by: Hongyu Ning <[email protected]>
- Loading branch information
Showing
6 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
halt_test.ko |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
|
||
MODULES = halt_test.ko | ||
|
||
obj-m += halt_test.o | ||
|
||
KDIR ?= /lib/modules/$(shell uname -r)/build | ||
|
||
all: | ||
make -C $(KDIR) M=$(PWD) modules | ||
clean: | ||
make -C $(KDIR) M=$(PWD) clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
#include <linux/init.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
|
||
static int __init test_tdx_hlt_init(void) | ||
{ | ||
pr_info("[TD guest test] Start to trigger hlt instr.\n"); | ||
asm("cli"); | ||
asm("hlt"); | ||
return 0; | ||
} | ||
|
||
static void __exit test_tdx_hlt_exit(void) | ||
{ | ||
pr_info("[TD guest test] Complete of hlt instr. test, test module exit\n"); | ||
} | ||
|
||
module_init(test_tdx_hlt_init); | ||
module_exit(test_tdx_hlt_exit); | ||
MODULE_INFO(intree, "Y"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# Copyright (c) 2023 Intel Corporation | ||
|
||
# Author: Hongyu Ning <[email protected]> | ||
# | ||
# History: 13, Dec., 2023 - Hongyu Ning - creation | ||
|
||
|
||
# @desc This script do test by kernel test module in TDX Guest VM | ||
|
||
###################### Variables ###################### | ||
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" | ||
echo "$SCRIPT_DIR" | ||
source common.sh | ||
test_module=$1 | ||
|
||
###################### Functions ###################### | ||
module_check() { | ||
lsmod | grep "$test_module" || \ | ||
{ die "test module $test_module not found in lsmod"; return 1; } | ||
test_print_trc "test module loaded and test should be completed now" | ||
} | ||
|
||
###################### Do Works ###################### | ||
if [[ -f "$test_module".ko ]]; then | ||
test_print_trc "Kernel test module: $test_module.ko is ready for test" | ||
insmod "$test_module".ko || \ | ||
{ die "Fail to insmod test module $test_module.ko"; exit 1; } | ||
test_print_trc "$test_module.ko inserted and hlt instruction triggered" | ||
module_check | ||
sleep 3 | ||
rmmod "$test_module" || \ | ||
{ die "Fail to rmmod test module $test_module.ko"; exit 1; } | ||
else | ||
die "Kernel test module $test_module.ko not found" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters