Skip to content

Instantly share code, notes, and snippets.

View cyyself's full-sized avatar

Yangyu Chen cyyself

View GitHub Profile
from pych9329 import HIDController, SerialTransport, CH9329
import time
PASSWORD = "123456"
def xiaomi_devmode(controller):
# assume it's already in settings
# press arrow down 3x to enter my device menu
for i in range(3):
controller.press("down")
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
KERNEL="${SCRIPT_DIR}/linux/arch/x86/boot/bzImage"
ROOTFS="${SCRIPT_DIR}/debian-root"
QMP_SOCK="${SCRIPT_DIR}/.qemu-qmp.sock"
# Host topology: AMD EPYC 7V73X
# 1 socket, 8 CCDs (dies), 8 cores/CCD, 2 threads/core = 128 vCPUs
@cyyself
cyyself / dtsgen.py
Last active December 2, 2025 16:46
#!/usr/bin/env python3
class DTSGen:
def __init__(self,
compatible: str = "xiangshan,nemu-board",
model: str = "XiangShan",
isa_extensions: list = ["i", "m", "a", "f", "d", "c"],
mmu_type="riscv,sv39",
timebase_freq: int = 10000000, # 10 MHz
nr_harts: int = 1,
@cyyself
cyyself / stdc++.h
Created May 29, 2025 07:55
stdc++.h for macOS
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2023 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
#!/usr/bin/env python3
PREFIX = "2001:470:19:a65:"
SUFFIX = "/64"
LEN = 14
print("brctl addbr pathgen")
print("ip link set pathgen up")
print("ip addr add %sffff:ffff:ffff:ffff%s dev pathgen" % (PREFIX, SUFFIX))
#!/usr/bin/env sh
# Check if multiple IPv6 addresses are assigned to the usb0 interface
# If so, we have deprecated addresses and need to restart the interface.
if [ $(cat /proc/net/if_inet6 | grep usb0 | wc -l) -gt 2 ]; then
ifdown wwan6
ifup wwan6
fi
#!/usr/bin/env sh
wg_filter="wg0 wg1" # EDITME
current_time=$(date +%s)
wg show all dump | awk '{if ($5 != "off") print $1,$6}' | while read -r each_dump; do
interface=$(echo $each_dump | cut -d' ' -f1)
last_handshake=$(echo $each_dump | cut -d' ' -f2)
if echo $wg_filter | grep -q $interface; then
if [ $((current_time - last_handshake)) -gt 240 ]; then
# ip-full kmod-veth iptables-nft ip6tables-mod-nat ip6tables-nft
ip6tables -t nat -A POSTROUTING -s fd05::1/64 -j MASQUERADE
ip link add 5g_lan type veth peer 5g_lan_peer
ip netns add 5g_lan
ip link set dev 5g_lan_peer netns 5g_lan
ip netns exec 5g_lan sh <<EOF
sysctl -w net.ipv4.conf.all.forwarding=1
sysctl -w net.ipv6.conf.all.forwarding=1
ip link set dev lo up
ip link set dev 5g_lan_peer up

We can trust the use of _dl_lookup_symbol_x during elf_machine_runtime_setup in SHARED is safe

Prove

These discussions are based on recent glibc commit a4c414796a.

I know it's hard to prove _dl_lookup_symbol_x being called at elf_machine_runtime_setup without l_relocated == 1 when we have #ifdef SHARED is safe. But if we trust another place it is being called is safe, and there is no change for the requested data structure between these 2 times , then it's natural to trust we call it here is safe.

We can prove this by debugging lib/ld-linux-riscv64-lp64d.so.1 in gdb. First, compile glibc commit a4c414796a with && l->l_relocated removed in sysdeps/riscv/dl-machines.h.

Related

issue: https://github.com/flatpak/xdg-desktop-portal/issues/1032

Error log:

~ systemctl --user status xdg-desktop-portal
● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal.service; static)
     Active: activating (start) since Tue 2024-11-26 12:41:59 CST; 1min 5s ago