Received: from eggs.gnu.org ([2001:4830:134:3::10]:43329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQN7a-0007lG-5u for qemu-devel@nongnu.org; Mon, 01 Feb 2016 17:38:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQN7W-0004qQ-VR for qemu-devel@nongnu.org; Mon, 01 Feb 2016 17:38:58 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:44291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQN7W-0004pX-Hz for qemu-devel@nongnu.org; Mon, 01 Feb 2016 17:38:54 -0500 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= Date: Mon, 01 Feb 2016 23:38:52 +0100 Message-ID: <87zivkgio3.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC] Programmable guest-to-QEMU hypercalls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl Hi! I have in my trace instrumentation queue a series that adds a very simple but efficient way to trigger code in QEMU from guest code using guest-agnostic code. Blue Swirl showed some interest long ago in using it in the test suite (e.g., instruct QEMU to check the vCPU state after a series of instructions). But I don't know if there still is interest, or if anybody else finds this useful (otherwise I'll keep it in my instrumentation branch). Guest-side interface: #include int main() { // initialize communication device qemu_hypercall_init("/tmp/hypercall"); // memory region to share data between guest and QEMU // (QEMU does not trap reads/writes here, so it can be used as a // bandwidth-efficient communication channel) void *data = qemu_hypercall_data(); ((char*)data)[0] = 0x1; // trigger hypercall callback qemu_hypercall(0xcafe); // in-line data } A dynamic library is loaded when starting QEMU, which gets called as a response to 'qemu_hypercall()': // libmyhypercall.so qemu_hypercall(uint64_t cmd, char *data) { assert(cmd == 0xcafe) assert(((char*)data)[0] == 0x1); } To start QEMU: qemu-x86_64 -hypercall libmyhypercall.so -hypercall-device=/tmp/backdoor /test/program qemu-system-x86_64 -device hypercall I have a prototype for a guest user library and a guest Linux module to use this in both user and system mode. Cheers, Lluis