qemu-cr16/tests/tcg/x86_64/system/patch-target.c
Rowan Hart 71d3379438 plugins: Add patcher plugin and test
This patch adds a plugin that exercises the virtual and hardware memory
read-write API functions added in a previous patch. The plugin takes a
target and patch byte sequence, and will overwrite any instruction
matching the target byte sequence with the patch.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Rowan Hart <rowanbhart@gmail.com>
Message-ID: <20250624175351.440780-8-rowanbhart@gmail.com>
[AJB: tweak Makefile, use uintptr_t for pointer stuffing]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250627112512.1880708-12-alex.bennee@linaro.org>
2025-07-02 10:09:48 +01:00

22 lines
474 B
C

/*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This test target increments a value 100 times. The patcher converts the
* inc instruction to a nop, so it only increments the value once.
*
*/
#include <minilib.h>
int main(void)
{
ml_printf("Running test...\n");
unsigned int x = 0;
for (int i = 0; i < 100; i++) {
asm volatile (
"inc %[x]"
: [x] "+a" (x)
);
}
ml_printf("Value: %d\n", x);
return 0;
}