/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2011 NetApp, Inc.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#include <sys/param.h>29#include <sys/libkern.h>3031#include <machine/md_var.h>3233#include "vmm_util.h"3435bool36vmm_is_hw_supported(void)37{38return (vmm_is_intel() || vmm_is_svm());39}4041bool42vmm_is_intel(void)43{4445return (strcmp(cpu_vendor, "GenuineIntel") == 0);46}4748bool49vmm_is_svm(void)50{51return (strcmp(cpu_vendor, "AuthenticAMD") == 0 ||52strcmp(cpu_vendor, "HygonGenuine") == 0);53}5455bool56vmm_supports_1G_pages(void)57{58unsigned int regs[4];5960/*61* CPUID.80000001:EDX[bit 26] = 1 indicates support for 1GB pages62*63* Both Intel and AMD support this bit.64*/65if (cpu_exthigh >= 0x80000001) {66do_cpuid(0x80000001, regs);67if (regs[3] & (1 << 26))68return (true);69}70return (false);71}7273#include <sys/proc.h>74#include <machine/frame.h>75#define DUMP_REG(x) printf(#x "\t\t0x%016lx\n", (long)(tf->tf_ ## x))76#define DUMP_SEG(x) printf(#x "\t\t0x%04x\n", (unsigned)(tf->tf_ ## x))77void78dump_trapframe(struct trapframe *tf)79{80DUMP_REG(rdi);81DUMP_REG(rsi);82DUMP_REG(rdx);83DUMP_REG(rcx);84DUMP_REG(r8);85DUMP_REG(r9);86DUMP_REG(rax);87DUMP_REG(rbx);88DUMP_REG(rbp);89DUMP_REG(r10);90DUMP_REG(r11);91DUMP_REG(r12);92DUMP_REG(r13);93DUMP_REG(r14);94DUMP_REG(r15);95DUMP_REG(trapno);96DUMP_REG(addr);97DUMP_REG(flags);98DUMP_REG(err);99DUMP_REG(rip);100DUMP_REG(rflags);101DUMP_REG(rsp);102DUMP_SEG(cs);103DUMP_SEG(ss);104DUMP_SEG(fs);105DUMP_SEG(gs);106DUMP_SEG(es);107DUMP_SEG(ds);108}109110111