Skip to content

Instantly share code, notes, and snippets.

View mbs0221's full-sized avatar
🏠
Working

Benshan Mei mbs0221

🏠
Working
View GitHub Profile
@Marcondiro
Marcondiro / intel_pt_kvm.md
Last active March 21, 2025 01:24
How to Enable Intel PT (Processor Trace) in QEMU-KVM VMs

How to Enable Intel PT (Processor Trace) in QEMU-KVM VMs

Caution

Intel PT virtualization is BROKEN, as it has multiple fatal flaws, several which put the host at risk. Use at your own risk.

This guide will most likely become obsolete once the feature will be removed from the various linux distros. For more info check out KVM: VMX: Mark Intel PT virtualization as BROKEN and CVE-2024-53135

This script sets KVM Processor Trace feature in host-guest mode enabling VMs to use intel-pt

@cGandom
cGandom / RaspberryPi4-qemu.md
Last active April 18, 2025 16:06
Emulating Raspberry Pi 4 with Qemu

Emulating Raspberry Pi 4 with Qemu

Just a quick update before we dive in: what we're actually doing here is running Raspberry Pi OS (64-bit) on a QEMU virtual ARM setup. This isn't full-blown hardware emulation of the Raspberry Pi 4, but more about creating a virtual environment for the OS. It doesn't mimic all the specific hardware features of the Pi 4, but it's pretty useful and great for general testing. I turned to this solution mainly to extract a modified sysroot from the Raspberry Pi OS, something not readily available in other resources. For those looking into detailed emulation of the actual Raspberry Pi 4's hardware in QEMU, check out this link for the latest updates: https://gitlab.com/qemu-project/qemu/-/issues/1208.

Hope it helps! :D

Shortcomings: No GUI yet, only console.

Steps

@Autoplay1999
Autoplay1999 / hwbp.cpp
Last active September 5, 2023 16:38
Hardware Breakpoint
#include "hwbp.h"
#include <deque>
#include <set>
#include <assert.h>
#include <TlHelp32.h>
#define DEBUG_GET_LOCAL_ENABLE(i,dr7) ((dr7 >> (i * 2)) & 0x1)
#define DEBUG_GET_CONDITION(i,dr7) ((dr7 >> (16 + i * 4)) & 0x3)
#define DEBUG_GET_LENGTH(i,dr7) ((dr7 >> (18 + i * 4)) & 0x3)
AMD EPYC 7V12 64-Core Processor
@TheNetAdmin
TheNetAdmin / mark-efi.py
Created August 16, 2022 09:26
Mark kvm-unit-tests EFI test cases
# build efi test cases and then `ls *.efi` to get this efi_tests list
efi_tests = [
"amd_sev",
"apic",
"asyncpf",
"cet",
"debug",
"dummy",
"emulator",
"eventinj",
@vwxi
vwxi / cpuidentifier.c
Created February 28, 2022 21:10
basic cpu identifier (32-bit windows)
/*
* cpuidentifier by pala
* written for 32-bit windows
*/
#include <stdio.h>
#include <string.h>
#define VERSION "1.0.0"
@bgaff
bgaff / repro.c
Created November 8, 2021 17:26
rdpkru - Intel 11th Gen Core CPU bug
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/mman.h>
#define BITS_PER_PKEY 2
static uint32_t rdpkru(void)
{
uint32_t ecx = 0;
@muturik
muturik / vmcs.hpp
Created August 22, 2021 23:05
VMCS field encodings
#include <ntifs.h>
#include <stdint.h>
/*
Even though you can simply copy from kvm, linux kernels, etc.., it's better to copy them yourself as they change, plus who wants
to rely on another project for updates?
made using: This document contains all four volumes of the Intel 64 and IA-32 Architectures Software
Developer's Manual: Basic Architecture, Order Number 253665; Instruction Set Reference A-Z, Order
Number 325383; System Programming Guide, Order Number 325384; Model-Specific Registers, Order
@kohnakagawa
kohnakagawa / check_cet_supported.c
Created March 27, 2021 07:53
Checks whether your cpu supports Intel CET or not (Linux).
#include <stdio.h>
#include <cpuid.h>
#include <stdint.h>
int cpu_supports_cet_shadow_stack() {
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
__cpuid_count(7, 0, eax, ebx, ecx, edx);
return (ecx & (1 << 7)) != 0;
}
@linuxthor
linuxthor / kfindsymprobe.c
Created September 11, 2020 21:55
Use a kprobe to find the address of some kernel symbol
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/kprobes.h>
static struct kprobe kp = {
.symbol_name = "kallsyms_lookup_name"
};
int init_module(void)