Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for OpenBSD 7.5 #573

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ EOM

cc_check_header()
{
${CC} ${PKG_CFLAGS} -x c -o /dev/null - <<EOM >/dev/null 2>&1
#include <$@>
(
for h in "$@"; do echo "#include <$h>"; done
cat << EOM

int main(int argc, char *argv[])
{
return 0;
}
EOM
) | ${CC} ${PKG_CFLAGS} -x c -o /dev/null - >/dev/null 2>&1
}

cc_check_lib()
Expand Down Expand Up @@ -282,6 +284,15 @@ case ${HOST_CC_MACHINE} in
amd64-*openbsd*)
CONFIG_HOST_ARCH=x86_64 CONFIG_HOST=OpenBSD
CONFIG_HVT_TENDER=1
echo "${prog_NAME}: Checking for dev/vmm/vmm.h availability: "
if CC="${HOST_CC}" PKG_CFLAGS="" \
cc_check_header sys/types.h machine/vmmvar.h dev/vmm/vmm.h; then
echo "yes"
echo "#define HAVE_VMM_H 1" >tenders/hvt/hvt_openbsd_config.h
else
echo "no"
echo "#undef HAVE_VMM_H" >tenders/hvt/hvt_openbsd_config.h
fi
;;
*)
die "Unsupported host toolchain: ${HOST_CC_MACHINE}"
Expand Down
5 changes: 5 additions & 0 deletions tenders/hvt/hvt_openbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
#include <machine/vmmvar.h>
#include <sys/param.h>

#include "hvt_openbsd_config.h"
#ifdef HAVE_VMM_H
#include <dev/vmm/vmm.h>
#endif

#include "hvt.h"
#include "hvt_openbsd.h"

Expand Down
12 changes: 11 additions & 1 deletion tenders/hvt/hvt_openbsd_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,20 @@
#include <machine/vmmvar.h>
#include <machine/specialreg.h>

#include "hvt_openbsd_config.h"
#ifdef HAVE_VMM_H
#include <dev/vmm/vmm.h>
#endif

#include "hvt.h"
#include "hvt_openbsd.h"
#include "hvt_cpu_x86_64.h"

/* XCR0_X87 is the pre-7.5 name for XFEATURE_X87 */
#ifndef XFEATURE_X87
#define XFEATURE_X87 XCR0_X87
#endif

static struct vcpu_segment_info sreg_to_vsi(const struct x86_sreg *);

static uint64_t get_tsc_freq(void)
Expand Down Expand Up @@ -124,7 +134,7 @@ void hvt_vcpu_init(struct hvt *hvt, hvt_gpa_t gpa_ep)
.vrs_msrs[VCPU_REGS_CSTAR] = 0ULL,
.vrs_msrs[VCPU_REGS_SFMASK] = 0ULL,
.vrs_msrs[VCPU_REGS_KGSBASE] = 0ULL,
.vrs_crs[VCPU_REGS_XCR0] = XCR0_X87
.vrs_crs[VCPU_REGS_XCR0] = XFEATURE_X87
}
};

Expand Down