Skip to content

Commit 25b0412

Browse files
AndrewQuijanolacraig2
authored andcommitted
Moving LAVA Hypercall struct to include
1 parent abd6f61 commit 25b0412

4 files changed

Lines changed: 52 additions & 24 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*!
2+
* @file lava_hypercall_struct.h
3+
* @brief Support for hypercalls from the PANDA guest to the taint2 plugin. Used by LAVA.
4+
*
5+
* @author
6+
* Tim Leek tleek@ll.mit.edu
7+
* Ryan Whelan rwhelan@ll.mit.edu
8+
* Joshua Hodosh josh.hodosh@ll.mit.edu
9+
* Michael Zhivich mzhivich@ll.mit.edu
10+
* Brendan Dolan-Gavitt brendandg@gatech.edu
11+
*
12+
* @copyright This work is licensed under the terms of the GNU GPL, version 2.
13+
* See the COPYING file in the top-level directory.
14+
*/
15+
#pragma once
16+
17+
#ifndef __LAVA_HYPERCALL_STRUCT_H__
18+
#define __LAVA_HYPERCALL_STRUCT_H__
19+
20+
// lavaint must be 32 bits for architecture compatibility (4 bytes)
21+
typedef unsigned int lavaint;
22+
#ifndef __cplusplus
23+
#define static_assert _Static_assert
24+
#endif
25+
static_assert(sizeof(lavaint) == 4, "lavaint size must be 4!");
26+
27+
// Magic number used by the host to identify the hypercall as a legitimate
28+
// call intended for the taint2 plugin.
29+
#define LAVA_MAGIC 0xabcd
30+
31+
// CRITICAL: Ensure 1-byte packing so the structure size and field offsets
32+
// match exactly between the guest and the host (no compiler padding).
33+
#pragma pack(push,1)
34+
typedef struct panda_hypercall_struct {
35+
lavaint magic; // Must be LAVA_MAGIC
36+
lavaint action; // label / query / etc
37+
lavaint buf; // ptr to memory we want labeled or queried or ...
38+
lavaint len; // number of bytes to label or query or ...
39+
lavaint label_num; // if labeling, this is the label number. if querying this should be zero
40+
lavaint src_column; // column on source line
41+
lavaint src_filename; // char * to filename.
42+
lavaint src_linenum; // line number
43+
lavaint src_ast_node_name; // the name of the l-value queries
44+
lavaint info; // general info
45+
lavaint insertion_point; // unused now.
46+
} PandaHypercallStruct;
47+
#pragma pack(pop)
48+
49+
#endif // __LAVA_HYPERCALL_STRUCT_H__

panda/plugins/pri_taint/pri_taint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern "C" {
2222
#include "panda/rr/rr_log.h"
2323
#include "panda/plog.h"
2424

25-
#include "taint2/taint2_hypercalls.h"
25+
#include "panda/lava_hypercall_struct.h"
2626

2727
#include "pri/pri_types.h"
2828
#include "pri/pri_ext.h"

panda/plugins/taint2/taint2_hypercalls.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <string>
2323
#include <map>
2424
#include <vector>
25+
#include "panda/lava_hypercall_struct.h"
2526
#include "taint2_hypercalls.h"
2627
#include "taint_api.h"
2728
#include "callstack_instr/callstack_instr.h"

panda/plugins/taint2/taint2_hypercalls.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* @note This is currently only used by LAVA. Make sure you keep this file
66
* in sync between the PANDA and LAVA repositories.
7+
* Check the panda/include/panda/lava_hypercall_struct.h file for the struct implementation
78
*
89
* @author
910
* Tim Leek tleek@ll.mit.edu
@@ -19,29 +20,6 @@
1920

2021
#include "qemu/osdep.h"
2122

22-
typedef unsigned int lavaint;
23-
#ifndef __cplusplus
24-
#define static_assert _Static_assert
25-
#endif
26-
static_assert(sizeof(lavaint) == 4, "lavaint size must be 4!");
27-
28-
#define LAVA_MAGIC 0xabcd
29-
#pragma pack(push,1)
30-
typedef struct panda_hypercall_struct {
31-
lavaint magic;
32-
lavaint action; // label / query / etc
33-
lavaint buf; // ptr to memory we want labeled or queried or ...
34-
lavaint len; // number of bytes to label or query or ...
35-
lavaint label_num; // if labeling, this is the label number. if querying this should be zero
36-
lavaint src_column; // column on source line
37-
lavaint src_filename; // char * to filename.
38-
lavaint src_linenum; // line number
39-
lavaint src_ast_node_name; // the name of the l-value queries
40-
lavaint info; // general info
41-
lavaint insertion_point; // unused now.
42-
} PandaHypercallStruct;
43-
#pragma pack(pop)
44-
4523
#ifdef __cplusplus
4624
extern "C" {
4725
#endif

0 commit comments

Comments
 (0)