@@ -58,3 +58,4 @@ pc-bios/optionrom/multiboot.bin
pc-bios/optionrom/multiboot.raw
.stgit-*
cscope.*
+backdoor/examples/print/guest/test
new file mode 100644
@@ -0,0 +1,13 @@
+This example simply defines instruction-based backdoors to print their
+arguments, along with a guest example code that makes use of backdoor
+instructions.
+
+To compile the host (quemu) run:
+ /path/to/qemu/configure --with-backdoor=/path/to/qemu/backdoor/examples/print/host/
+ make
+
+To compile the guest program run:
+ make -C /path/to/qemu/backdoor/examples/print/guest/
+
+Now you can run it with:
+ /path/to/qemu/i386-linux-user/qemu-i386 /path/to/qemu/backdoor/examples/print/guest/test
new file mode 100644
@@ -0,0 +1,7 @@
+CFLAGS += -I../../../../
+PROGS = test
+
+all: $(PROGS)
+
+clean:
+ rm -f $(PROGS)
new file mode 100644
@@ -0,0 +1,33 @@
+/*
+ * Sample guest program exercising instruction-based backdoor communication.
+ *
+ * Copyright (c) 2010 Lluís Vilanova <vilanova@ac.upc.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+
+#include "backdoor/guest.h"
+
+int main ()
+{
+ int i = 23;
+ printf("i8 1\n");
+ BACKDOOR_i8(0x01);
+ printf("i8_v32 1 32\n");
+ BACKDOOR_i8_v32(0x01, 32);
+ printf("i8_v32 2 i (%d)\n", i);
+ BACKDOOR_i8_v32(0x02, i);
+}
new file mode 100644
@@ -0,0 +1,13 @@
+# Makefile for user-provided backdoor code
+
+include $(SRC_PATH)/config-host.mak
+include $(SRC_PATH)/rules.mak
+include $(SRC_PATH)/Makefile.objs
+
+objs = printcb.o
+
+libbackdoor.a: $(objs)
+ $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@")
+
+clean:
+ rm -f libbackdoor.a $(objs)
new file mode 100644
@@ -0,0 +1,36 @@
+/*
+ * Sample user-defined callbacks for backdoor communication.
+ *
+ * Copyright (c) 2010 Lluís Vilanova <vilanova@ac.upc.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+
+#include "cpu.h"
+#include "helper.h"
+
+
+void
+helper_backdoor_i8 (uint32_t imm)
+{
+ printf("backdoor_i8: %u\n", imm);
+}
+
+void
+helper_backdoor_i8_v32 (uint32_t imm, uint32_t value)
+{
+ printf("backdoor_i8_v32: %u %d\n", imm, value);
+}
Provides a guest application that exercices the instruction-based backdoor communication, as well as a backdoor callback implementation that prints the guest requests. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> --- .gitignore | 1 + backdoor/examples/print/README | 13 ++++++++++++ backdoor/examples/print/guest/Makefile | 7 ++++++ backdoor/examples/print/guest/test.c | 33 +++++++++++++++++++++++++++++ backdoor/examples/print/host/Makefile | 13 ++++++++++++ backdoor/examples/print/host/printcb.c | 36 ++++++++++++++++++++++++++++++++ 6 files changed, 103 insertions(+), 0 deletions(-) create mode 100644 backdoor/examples/print/README create mode 100644 backdoor/examples/print/guest/Makefile create mode 100644 backdoor/examples/print/guest/test.c create mode 100644 backdoor/examples/print/host/Makefile create mode 100644 backdoor/examples/print/host/printcb.c