特权指令与敏感指令 / Sensitive instructions and privilege instructions

大多数的现代计算机体系结构都有两个或以上的特权级,用来分隔系统软件和应用软件。系统中有一些操作和管理关键系统资源的指令会被定为特权指令,这些指令只有在最高特权级上能够正确执行。如果在非最高特权级上运行,特权指令会引发一个异常,处理器会陷入到最高特权级,交由系统软件来处理。

在不同的特权级上,不仅指令的执行效果是不同的,而且也并不是每个特权指令都会引发异常,假如一个 x86 平台的用户违反了规范,在用户态修改 EFLAGS 寄存器的中断开关位,这一修改将不会产生任何效果,也不会引起异常陷入,而是会被硬件直接忽略掉。

在虚拟化世界里,还有另一类指令被称作为敏感指令,简言之就是操作特权资源的指令,包括修改虚拟机的运行模式或者下面物理机的状态;读写敏感的寄存器或是内存,例如时钟或者中断寄存器;访问存储保护系统、内存系统或是地址重定位系统;以及所有的 I/O 指令。

敏感指令是 Guest 执行了之后会引发 VMExit 的指令。

显而易见,所有的特权指令都是敏感指令,然而并不是所有的敏感指令都是特权指令。

摘自《系统虚拟化 原理与实现》。

Ctrl z, fg and bg

postgresql - How to restart some progress which is stopped by "ctrl+z"? - Stack Overflow

Use of ! in VIM

What's the use of the exclamation mark ('!') in Vim's command line after certain commands like ":w!"? - Stack Overflow

CSP

Cloud Solution Provider

基本块

在电脑 编译器 架构中,基本块(basic block)是一段线性的程式码,只能从这段程式码开始处进入这段程式,没有其他程式码会跳跃进入这段程式,只能从这段程式码最后一行离开这段程式,中间没有其他程式码会跳跃离开这段程式。

中断返回指令 IRET

The IRET (return from interrupt) instruction returns program control from an interrupt handler to the interrupted procedure. The IRET instruction performs a similar operation to the RET instruction.

See SDM 7.3.8.4 Software Interrupt Instructions.

Win10 系统优化

Sycnex/Windows10Debloater: Script to remove Windows 10 bloatware.

Yet Another Dotfiles Manager

"Yet Another Dotfiles Manager - yadm"

Polling

轮询

C-State / P-State

C-states are idle power saving states, in contrast to P-states, which are execution power saving states.

During a P-state, the processor is still executing instructions, whereas during a C-state (other than C0), the processor is idle, meaning that nothing is executing.

A new CPU driver intel_pstate was added to the Linux kernel 3.9 (April 2009).

When a logical processor is idle (C-state except of C0), its frequency is typically 0 (HALT).

CPU cores can be completely turned off (CPU HALT, frequency of 0) temporarily to reduce the power consumption, and the frequency of cores changes regulary depending on many factors like the workload and temperature.

The processor P-state is the capability of running the processor at different voltage and/or frequency levels. Generally, P0 is the highest state resulting in maximum performance, while P1, P2, and so on, will save power but at some penalty to CPU performance.

Turbo Boost allows to run one or many CPU cores to higher P-states than usual. The maximum P-state is constrained by the following factors:

The number of active cores (in C0 or C1 state)

The estimated current consumption of the processor (Imax)

The estimated power consumption (TDP - Thermal Design Power) of processor

The temperature of the processor

It looks like the most reliable way to get a relialistic estimation of the CPUs frequency is to use the tool turbostat.

Typically, they are used along with algorithms to estimate the required CPU capacity, so as to decide which P-states to put the CPUs into. Of course, since the utilization of the system generally changes over time, that has to be done repeatedly on a regular basis. The activity by which this happens is referred to as CPU performance scaling or CPU frequency scaling.

CPU Performance Scaling — The Linux Kernel documentation

Intel CPUs: P-state, C-state, Turbo Boost, CPU frequency, etc. — Victor Stinner blog 3

什么是 C-State? | Dell 中国

Charm

We build tools to make the command line glamorous.

"Charm"

part of the

Grammarly for vim

"dpelle/vim-LanguageTool: A vim plugin for the LanguageTool grammar checker"

"Copyright vs. Copyleft"

VMCS Layout

cpu-internals/VMCS-Layout.pdf at master · LordNoteworthy/cpu-internals (github.com)

sTooltip - colored standard tooltip with timeout

"[function] sTooltip - colored standard tooltip with timeout - Scripts and Functions - AutoHotkey Community"

Your code editor, black on white or white on black?

Ask HN: Your code editor, black on white or white on black? | Hacker News

Georgia (typeface)

"Georgia (typeface) - Wikipedia"

SOMESOMEsome some some SOME SOME SOME 所么所么 SOME SOME some

For each vCPU there is one VMCS. This means that VMCS stores information on CPU-level granularity and not VM level.

"Intel Virtualisation: How VT-x, KVM and QEMU Work Together – Binary Debt"

Most ioctl implementations consist of a switch statement. It selects the correct behavior according to the cmd argument.

"char-enhanced.pdf"

Tampermonkey

This plugin can add Javascript scripts to any site, so I can replace some characters in title to enhance the copy as markdown style feature.

Magic number

motivation:

Before writing the code for ioctl, you need to choose the numbers that correspond to commands. Unfortunately, the simple choice of using small numbers starting from 1 and going up doesn’t work well. The command numbers should be unique across the system. In order to prevent errors caused by issuing the right command to the wrong device.1

Two device nodes may have the same major number. An application could open more than one device and mix up the file descriptors, thereby sending the right command to the wrong device. Sending wrong ioctl commands can have catastrophic consequences, including damage to hardware. A unique magic number should be encoded into the commands with one of the following macros.2

_IO (magic, number)
_IOR (magic, number, data_type)
_IOW (magic, number, data_type)
_IORW(magic, number, data_type)

where magic is the 8-bit magic number unique to the device.

Ioctl for block device

Block devices can provide an ioctl method to perform device control functions. The higher-level block subsystem code intercepts a number of ioctl commands before your driver ever gets to see them, however (see drivers/block/ioctl.c in the kernel source for the full set). In fact, a modern block driver may not have to implement very many ioctl commands at all.3

Core difference between char device and block device

Character devices are those for which no buffering is performed, and block devices are those which are accessed through a cache.

Character devices are read from and written to with two function: foo_read() and foo_write(). The read() and write() calls do not return until the operation is complete. By contrast, block devices do not even implement the read() and write() functions, and instead have a function which has historically been called the ``strategy routine.'' Reads and writes are done through the buffer cache mechanism by the generic functions bread(), breada(), and bwrite(). These functions go through the buffer cache, and so may or may not actually call the strategy routine, depending on whether or not the block requested is in the buffer cache (for reads) or on whether or not the buffer cache is full (for writes). A request may be asyncronous: breada() can request the strategy routine to schedule reads that have not been asked for, and to do it asyncronously, in the background, in the hopes that they will be needed later.

The sources for character devices are kept in drivers/char/, and the sources for block devices are kept in drivers/block/. They have similar interfaces, and are very much alike, except for reading and writing. Because of the difference in reading and writing, initialization is different, as block devices have to register a strategy routine, which is registered in a different way than the foo_read() and foo_write() routines of a character device driver.4

Telescope documentation for developers

telescope.nvim/developers.md at master · nvim-telescope/telescope.nvim

Write back vs write through cache

Write Through and Write Back in Cache - GeeksforGeeks

Intel vPro

Intel vPro technology is an umbrella marketing term used by Intel for a large collection of computer hardware technologies, including VT-x, VT-d, Trusted Execution Technology (TXT), and Intel Active Management Technology (AMT).

Compare two branches in Github

To compare different versions of your repository, append /compare to your repository's path.

git - How can I diff two branches in GitHub? - Stack Overflow

How to chsh in wsl

bash - How to change default shell for Linux susbsystem for Windows - Super User

VMCS/VMCB

Intel calls it: VMCS

AMD calls it: VMCB

EPT/NPT

Intel: EPT(Extended Page Tables)

AMD: NPT(Nested Page Tables)

Gfn

guest frame number.

Mkview and loadview

A View is the smallest subset of the three (View, Session, Viminfo). It is a collection of settings for one window.

Views, Sessions, And Viminfo | Learn Vim

Nvim-cmp builtin comparators

nvim-cmp/compare.lua at main · hrsh7th/nvim-cmp

All the lsp symbol kind name

export namespace SymbolKind {
	export const File = 1;
	export const Module = 2;
	export const Namespace = 3;
	export const Package = 4;
	export const Class = 5;
	export const Method = 6;
	export const Property = 7;
	export const Field = 8;
	export const Constructor = 9;
	export const Enum = 10;
	export const Interface = 11;
	export const Function = 12;
	export const Variable = 13;
	export const Constant = 14;
	export const String = 15;
	export const Number = 16;
	export const Boolean = 17;
	export const Array = 18;
	export const Object = 19;
	export const Key = 20;
	export const Null = 21;
	export const EnumMember = 22;
	export const Struct = 23;
	export const Event = 24;
	export const Operator = 25;
	export const TypeParameter = 26;
}

from Specification.

Default neovim highlight groups

Nvim documentation: syntax (neovim.io)

Remote tracking branch

Remote-tracking branches are references to the state of remote branches. They’re local references that you can’t move; Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository.

Remote-tracking branch names take the form <remote>/<branch>.5

全角和半角

全角半角是文字的两种显示形式,“全角”指文字字身长宽比为一比一的正方形,而“半角”为宽度为全角一半的文字。

“半角/全角”源于日文,其中“角”是“方块”的意思,“全角/半角”在日文里即是原本“正方形/半个正方形大小文字”的本意。

fullwidth and halfwidth.

Cherry-pick order matters

git - Cherrypick commit orders - Stack Overflow

By default, any function that is defined in a C file is extern.

What is extern and static function in C? | Fresh2Refresh.com

VIM tab configurations for Linux Kernel Development

VIM configurations for Linux Kernel Development

Kernel develop commit pretty format

The following git config settings can be used to add a pretty format for outputting the above style in the git log or git show commands:

[core]
        abbrev = 12
[pretty]
        fixes = Fixes: %h (\"%s\")

An example call:

$ git log -1 --pretty=fixes 54a4f0239f2e
Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")

Linux coding style notes

  • Outside of comments, documentation and except in Kconfig, spaces are never used for indentation.
  • The limit on the length of lines is 80 columns and this is a strongly preferred limit.
  • never break user-visible strings such as printk messages, because that breaks the ability to grep for them.

Use clang-format to fix kernel coding style

clang-format — The Linux Kernel documentation

Formatting in clangd / clang-format

clangd embeds clang-format, which can reformat your code: fixing indentation, breaking lines, and reflowing comments.

clangd respects your project’s .clang-format file which controls styling options.

Format-as-you-type is experimental and doesn’t work well yet.

Features

Why doesn't lua support POSIX regular expression?

Unlike several other scripting languages, Lua does not use POSIX regular expressions (regexp) for pattern matching. The main reason for this is size: A typical implementation of POSIX regexp takes more than 4,000 lines of code. This is bigger than all Lua standard libraries together. In comparison, the implementation of pattern matching in Lua has less than 500 lines. Of course, the pattern matching in Lua cannot do all that a full POSIX implementation does. Nevertheless, pattern matching in Lua is a powerful tool and includes some features that are difficult to match with standard POSIX implementations.

Programming in Lua : 20.1

Patterns in Lua

Programming in Lua : 20.2

Offset and exact in nvim-cmp

separated-word
│         │
│         └ source2 offset
└ source1 offset

The offset comparator prefers source1 candidates.

The exact comparator prefers exact match candidates.

  1. Exact match
    • The user input is word and candidates text is word
  2. Not exact match
    • The user input is word and candidates text is wording

Add doc for comparators · Issue #883 · hrsh7th/nvim-cmp

Motivation behind git patch

GIT patch or GIT diff is used to share the changes made by you to others without pushing it to main branch of the repository.

How do I get a linux kernel patch set from the mailing list?

Ubuntu Manpage: mbox-extract-patch - extract a git patch series from an mbox

Using patchwork to manage your patch

getpatchwork/patchwork: Patchwork is a web-based patch tracking system designed to facilitate the contribution and management of contributions to an open-source project.

What is the difference between git am and git apply?

Both the input and output are different:

  • git apply takes a patch (e.g. the output of git diff) and applies it to the working directory (or index, if --index or --cached is used), which means it won't commit automatically, even won't add it if you use the default option.
  • git am takes a mailbox of commits formatted as an email messages (e.g. the output of git format-patch) and applies them to the current branch.

git am uses git apply behind the scenes, but does more work before (reading a Maildir or mbox, and parsing email messages) and after (creating commits).

patch - What is the difference between git am and git apply? - Stack Overflow

Commit message in patch

git format-patch will use the first line of the commit message to generate patch title. and the rest of the commit message to format the commit body.

gitter.im

Gitter is a chat and networking platform that helps to manage, grow and connect communities through messaging, content and discovery.

Gitter — Where developers come to talk.

<cr>, <tab> And <esc> are considered equivalent to <c-m>, <c-i> and <c-[> in terminal

key bindings - How to distinguish C-m from RETURN? - Emacs Stack Exchange

Patchew Project: A patch tracking and testing system

Patchew Project

如何在 Windows 或 Mac 上找到 Outlook 中的 SMTP 服务器

如何在Windows或Mac上找到Outlook中的SMTP服务器

Microsoft Exchange Server

Microsoft Exchange Server is a mail server and calendaring server developed by Microsoft. It runs exclusively on Windows Server operating systems.

Microsoft Exchange Server - Wikipedia

Config git send-email

How to configure and use git send-email to work with gmail to email patches to developers - Stack Overflow

森林集输入法皮肤

森林集官方皮肤站

柚子输入法、影子输入法:用 Ahk 实现的输入法

You's 输入法 - 文集 - 简书

河许人/影子输入法 - 码云 - 开源中国

Thunderbird cannot send

FIX: Send and Attach Buttons Missing in Thunderbird

Thunderbird export settings

how can I tansfer my Thunderbird account settings onto a new clean install on Windows 7? | Thunderbird Support Forum | Mozilla Support

Don't Use Terminal Emacs

Don't Use Terminal Emacs - The Chronicle

Add-apt-repository with proxy

sudo -E add-apt-repository

How do I get add-apt-repository to work through a proxy? - Ask Ubuntu

Sudo apt-key adv --keyserver 卡住不动怎么解决?

加一个 proxy:

sudo apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy=http://address:port --recv-keys <the_key>

详参:debian - Unable to add gpg key with apt-key behind a proxy - Unix & Linux Stack Exchange

How to find out which partition is Ubuntu installed on?

partitioning - How to find out which partition is Ubuntu installed on? - Ask Ubuntu

dlopen(): Error loading libfuse.so.2 AppImages require FUSE to run.

FUSE · AppImage/AppImageKit Wiki

Error: failed to connect to the hypervisor, error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-sock': No such file or directory

sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system virtinst bridge-utils
sudo systemctl enable libvirtd
sudo systemctl start libvirtd

virtualization - Failed to connect socket to '/var/run/libvirt/libvirt-sock' - Ask Ubuntu

Libvirt domain XML format

libvirt: Domain XML format

Converting QEMU arguments to domain XML

14.5.21. Converting QEMU Arguments to Domain XML Red Hat Enterprise Linux 6 | Red Hat Customer Portal

but unfortunetly it has been removed…

kvm - Qemu Native to Libvirt XML - Stack Overflow

Why are vms in KVM/QEMU called domains?

They're not kvm exclusive terminology. A hypervisor is a rough equivalent to domain zero, or dom0, which is the first system initialized on the kernel and has special privileges. Other domains started later are called domU and are the equivalent to a guest system or virtual machine.

Why are vms in KVM/QEMU called domains? - Unix & Linux Stack Exchange

Difference between virsh define and virsh create

本质上两者一样的,都是从 xml 配置文件创建虚拟机:

  • define 丛 xml 配置文件创建主机但是不启动;
  • create 同样是丛 xml 配置文件创建主机,但是可以指定很多选项,比如是否启动,是否连接控制台。

Virsh中创建虚拟机两种方式define和create的区别_weixin_34362991的博客-CSDN博客

Error: Disconnected from qemu:///session due to end of file, error: Failed to define domain from /etc/libvirt/qemu/ubuntu22.xml, error: End of file while reading data: Input/output error

使用 sudo 来运行。

Virsh cannot shutdown

just destroy it.

Virsh add port forward

Networking - Libvirt Wiki

什么是网桥?

两口交换机相当于一个网桥:

如何通俗地解释什么是网桥? - 知乎

什么是桥接?

桥接是指将两个或多个广播域(链路层)连接成一个广播域,使其中的设备可以在链路层互联。6

桥接就是将两个以太网连起来变成一个大的以太网。7

Network bridging for virtual machines

How to use bridged networking with libvirt and KVM - Linux Tutorials - Learn Linux Configuration

Virbr0 and br0

理解 virbr0_wuji3390的博客-CSDN博客_virbr0

Git clone into an existing folder

cd
git clone https://github.com/tristone13th/.config.git temp
mv temp/.git .config/.git
rm -rf temp
cd .config
git checkout .

CPU stepping

如果仔细的比较就会发现,步进实际上与某款特定型号的 处理器 无关,一款特定步进的晶元可以应用在多款处理器上,因此步进代表的其实是处理器制造工艺的某个阶段。比如两颗 处理器Core 2 E6400 和 Core 2 E6700,它们的步进都是 B2,这表示它们使用了相同的制造工艺。对于 超频 来说,这一概念是非常重要的:相同制程的 处理器,应当具备接近的极限频率。8

这篇文章讲的不错:

CPU Stepping - baihuahua - 博客园

什么是 Tape-out,也就是下线?

In electronics and photonics design, tape-out or tapeout is the final result of the design process for integrated circuits or printed circuit boards before they are sent for manufacturing. The tapeout is specifically the point at which the graphic for the photomask of the circuit is sent to the fabrication facility.

Tab groups in edge

Microsoft Edge gets Tab groups Collapse & Automatic creation features

Linux 小版本号是什么意思,比如 5.17.4 里的 4

The current version numbering is slightly different from the above. The even vs. odd numbering has been dropped and a specific major version is now indicated by the first two numbers, taken as a whole. While the time-frame is open for the development of the next major, the -rcN suffix is used to identify the n'th release candidate for the next version.[39] For example, the release of the version 4.16 was preceded by seven 4.16-rcN (from -rc1 to -rc7). Once a stable release is made, its maintenance is passed off to the “stable team". Occasional updates to stable releases are identified by a three numbering scheme (e.g., 4.13.1, 4.13.2, …, 4.13.16).

Linux kernel - Wikipedia

What is linux-next?

up-to-the-second, bleeding-edge status of Linus's tree.

development work should be done against the linux-next tree rather than against the mainline kernel.

Link to Text Fragment - Chrome 网上应用店

如何给博客加上搜索功能

使用Chrome自定义搜索引擎快速查找资源 - @Lenciel

Conceal feature in vim

khzaw/vim-conceal: A vim plugin making use of vim's conceal feature for additional visual eyecandy.

Neorg, orgmode and markdown

nvim-neorg/neorg: Modernity meets insane extensibility. The future of organizing your life in Neovim.

neovim 也有自己的标记语言了,码住以后说不定会用上,可以用来记笔记什么的,就是目前还没有办法支持 pandoc 转成 markdown,所以估计还是没有办法放到博客上。

三热技术

热升级、热替换、热迁移。

小狼毫输入法相关文档

入门:

Schema.yaml 詳解:

定制指南:

userdb 自定义修改(注意 c, d, t 三个参数):

如何删除不想要的词:

码表就是字典,字典就是码表。

A nice fuzzy finder implementation for Neovim

nvim-telescope/telescope-fzf-native.nvim: FZF sorter for telescope written in c

References: