mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 23:21:31 +00:00
6d75c6f40a
* Reorganise the arm64 kernel VA space and add support for LPA2 (at stage 1, KVM stage 2 was merged earlier) - 52-bit VA/PA address range with 4KB and 16KB pages * Enable Rust on arm64 * Support for the 2023 dpISA extensions (data processing ISA), host only * arm64 perf updates: - StarFive's StarLink (integrates one or more CPU cores with a shared L3 memory system) PMU support - Enable HiSilicon Erratum 162700402 quirk for HIP09 - Several updates for the HiSilicon PCIe PMU driver - Arm CoreSight PMU support - Convert all drivers under drivers/perf/ to use .remove_new() * Miscellaneous: - Don't enable workarounds for "rare" errata by default - Clean up the DAIF flags handling for EL0 returns (in preparation for NMI support) - Kselftest update for ptrace() - Update some of the sysreg field definitions - Slight improvement in the code generation for inline asm I/O accessors to permit offset addressing - kretprobes: acquire regs via a BRK exception (previously done via a trampoline handler) - SVE/SME cleanups, comment updates - Allow CALL_OPS+CC_OPTIMIZE_FOR_SIZE with clang (previously disabled due to gcc silently ignoring -falign-functions=N) -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE5RElWfyWxS+3PLO2a9axLQDIXvEFAmXxiSgACgkQa9axLQDI XvHd7hAAjQrQqxJogPT2ahM5/gxct8qTrXpIgX0B1Y7bb5R8ztvOUN9MJNuDyRsj 0s28SSZw387LReM5OUu+U6G/iahcuNAyP/8d9qeac32Tidd255fV3KPEh4C4eC+u 0HeOqLBZ+stmNoa71tBC2K6SmchizhYyYduvRnri8km8K4OMDawHWqWRTXl0PNRT RMVJvZTDJMPfMBFeD4+B7EnSFOoP14tKCw9MZvlbpT2PEV0kINjhCQiojW2jJgqv w36vm/dhwsg1avSzT1xhy3KE+m+7n28+IC/wr1HB7c1WumvYKv7Z84ieCp3PlO3Z owvVO7dKJC6X3RkoY6Kge5p2RHU6poDerDVHYiAvG+Zi57nrDmHyAubskThsGTGR AibSEeJ5nQ0yM6hx7zAIQa5XEo4l0svD1ZM7NynY+5JR44W9cdAH3SnEsvIBMGIf /ja+iZ1W4ZQnIESQXD5uDPSxILfqQ8Ebhdorpw+Qg3rB7OhdTdGSSGQCi6V2PcJH d/ErFO+i0lFRBPJtBbUAN4EEu3HJcVYEoEnVJYQahC+6KyNGLxO+7L6sH0YO7Pag P1LRa6h8ktuBMrbCrOPWdmJYNDYCbb5rRtmcCwO0ItZ4g5tYWp9djFc8pyctCaNB MZxxRrUCNwXTOcFTDiYzyk+JCvpf3EvXfvj8AH+P8BMjFWgqHqw= =KTD/ -----END PGP SIGNATURE----- Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux Pull arm64 updates from Catalin Marinas: "The major features are support for LPA2 (52-bit VA/PA with 4K and 16K pages), the dpISA extension and Rust enabled on arm64. The changes are mostly contained within the usual arch/arm64/, drivers/perf, the arm64 Documentation and kselftests. The exception is the Rust support which touches some generic build files. Summary: - Reorganise the arm64 kernel VA space and add support for LPA2 (at stage 1, KVM stage 2 was merged earlier) - 52-bit VA/PA address range with 4KB and 16KB pages - Enable Rust on arm64 - Support for the 2023 dpISA extensions (data processing ISA), host only - arm64 perf updates: - StarFive's StarLink (integrates one or more CPU cores with a shared L3 memory system) PMU support - Enable HiSilicon Erratum 162700402 quirk for HIP09 - Several updates for the HiSilicon PCIe PMU driver - Arm CoreSight PMU support - Convert all drivers under drivers/perf/ to use .remove_new() - Miscellaneous: - Don't enable workarounds for "rare" errata by default - Clean up the DAIF flags handling for EL0 returns (in preparation for NMI support) - Kselftest update for ptrace() - Update some of the sysreg field definitions - Slight improvement in the code generation for inline asm I/O accessors to permit offset addressing - kretprobes: acquire regs via a BRK exception (previously done via a trampoline handler) - SVE/SME cleanups, comment updates - Allow CALL_OPS+CC_OPTIMIZE_FOR_SIZE with clang (previously disabled due to gcc silently ignoring -falign-functions=N)" * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (134 commits) Revert "mm: add arch hook to validate mmap() prot flags" Revert "arm64: mm: add support for WXN memory translation attribute" Revert "ARM64: Dynamically allocate cpumasks and increase supported CPUs to 512" ARM64: Dynamically allocate cpumasks and increase supported CPUs to 512 kselftest/arm64: Add 2023 DPISA hwcap test coverage kselftest/arm64: Add basic FPMR test kselftest/arm64: Handle FPMR context in generic signal frame parser arm64/hwcap: Define hwcaps for 2023 DPISA features arm64/ptrace: Expose FPMR via ptrace arm64/signal: Add FPMR signal handling arm64/fpsimd: Support FEAT_FPMR arm64/fpsimd: Enable host kernel access to FPMR arm64/cpufeature: Hook new identification registers up to cpufeature docs: perf: Fix build warning of hisi-pcie-pmu.rst perf: starfive: Only allow COMPILE_TEST for 64-bit architectures MAINTAINERS: Add entry for StarFive StarLink PMU docs: perf: Add description for StarFive's StarLink PMU dt-bindings: perf: starfive: Add JH8100 StarLink PMU perf: starfive: Add StarLink PMU support docs: perf: Update usage for target filter of hisi-pcie-pmu ...
192 lines
5.7 KiB
Rust
192 lines
5.7 KiB
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
//! The custom target specification file generator for `rustc`.
|
|
//!
|
|
//! To configure a target from scratch, a JSON-encoded file has to be passed
|
|
//! to `rustc` (introduced in [RFC 131]). These options and the file itself are
|
|
//! unstable. Eventually, `rustc` should provide a way to do this in a stable
|
|
//! manner. For instance, via command-line arguments. Therefore, this file
|
|
//! should avoid using keys which can be set via `-C` or `-Z` options.
|
|
//!
|
|
//! [RFC 131]: https://rust-lang.github.io/rfcs/0131-target-specification.html
|
|
|
|
use std::{
|
|
collections::HashMap,
|
|
fmt::{Display, Formatter, Result},
|
|
io::BufRead,
|
|
};
|
|
|
|
enum Value {
|
|
Boolean(bool),
|
|
Number(i32),
|
|
String(String),
|
|
Object(Object),
|
|
}
|
|
|
|
type Object = Vec<(String, Value)>;
|
|
|
|
/// Minimal "almost JSON" generator (e.g. no `null`s, no arrays, no escaping),
|
|
/// enough for this purpose.
|
|
impl Display for Value {
|
|
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result {
|
|
match self {
|
|
Value::Boolean(boolean) => write!(formatter, "{}", boolean),
|
|
Value::Number(number) => write!(formatter, "{}", number),
|
|
Value::String(string) => write!(formatter, "\"{}\"", string),
|
|
Value::Object(object) => {
|
|
formatter.write_str("{")?;
|
|
if let [ref rest @ .., ref last] = object[..] {
|
|
for (key, value) in rest {
|
|
write!(formatter, "\"{}\": {},", key, value)?;
|
|
}
|
|
write!(formatter, "\"{}\": {}", last.0, last.1)?;
|
|
}
|
|
formatter.write_str("}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct TargetSpec(Object);
|
|
|
|
impl TargetSpec {
|
|
fn new() -> TargetSpec {
|
|
TargetSpec(Vec::new())
|
|
}
|
|
}
|
|
|
|
trait Push<T> {
|
|
fn push(&mut self, key: &str, value: T);
|
|
}
|
|
|
|
impl Push<bool> for TargetSpec {
|
|
fn push(&mut self, key: &str, value: bool) {
|
|
self.0.push((key.to_string(), Value::Boolean(value)));
|
|
}
|
|
}
|
|
|
|
impl Push<i32> for TargetSpec {
|
|
fn push(&mut self, key: &str, value: i32) {
|
|
self.0.push((key.to_string(), Value::Number(value)));
|
|
}
|
|
}
|
|
|
|
impl Push<String> for TargetSpec {
|
|
fn push(&mut self, key: &str, value: String) {
|
|
self.0.push((key.to_string(), Value::String(value)));
|
|
}
|
|
}
|
|
|
|
impl Push<&str> for TargetSpec {
|
|
fn push(&mut self, key: &str, value: &str) {
|
|
self.push(key, value.to_string());
|
|
}
|
|
}
|
|
|
|
impl Push<Object> for TargetSpec {
|
|
fn push(&mut self, key: &str, value: Object) {
|
|
self.0.push((key.to_string(), Value::Object(value)));
|
|
}
|
|
}
|
|
|
|
impl Display for TargetSpec {
|
|
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result {
|
|
// We add some newlines for clarity.
|
|
formatter.write_str("{\n")?;
|
|
if let [ref rest @ .., ref last] = self.0[..] {
|
|
for (key, value) in rest {
|
|
write!(formatter, " \"{}\": {},\n", key, value)?;
|
|
}
|
|
write!(formatter, " \"{}\": {}\n", last.0, last.1)?;
|
|
}
|
|
formatter.write_str("}")
|
|
}
|
|
}
|
|
|
|
struct KernelConfig(HashMap<String, String>);
|
|
|
|
impl KernelConfig {
|
|
/// Parses `include/config/auto.conf` from `stdin`.
|
|
fn from_stdin() -> KernelConfig {
|
|
let mut result = HashMap::new();
|
|
|
|
let stdin = std::io::stdin();
|
|
let mut handle = stdin.lock();
|
|
let mut line = String::new();
|
|
|
|
loop {
|
|
line.clear();
|
|
|
|
if handle.read_line(&mut line).unwrap() == 0 {
|
|
break;
|
|
}
|
|
|
|
if line.starts_with('#') {
|
|
continue;
|
|
}
|
|
|
|
let (key, value) = line.split_once('=').expect("Missing `=` in line.");
|
|
result.insert(key.to_string(), value.trim_end_matches('\n').to_string());
|
|
}
|
|
|
|
KernelConfig(result)
|
|
}
|
|
|
|
/// Does the option exist in the configuration (any value)?
|
|
///
|
|
/// The argument must be passed without the `CONFIG_` prefix.
|
|
/// This avoids repetition and it also avoids `fixdep` making us
|
|
/// depend on it.
|
|
fn has(&self, option: &str) -> bool {
|
|
let option = "CONFIG_".to_owned() + option;
|
|
self.0.contains_key(&option)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let cfg = KernelConfig::from_stdin();
|
|
let mut ts = TargetSpec::new();
|
|
|
|
// `llvm-target`s are taken from `scripts/Makefile.clang`.
|
|
if cfg.has("ARM64") {
|
|
panic!("arm64 uses the builtin rustc aarch64-unknown-none target");
|
|
} else if cfg.has("X86_64") {
|
|
ts.push("arch", "x86_64");
|
|
ts.push(
|
|
"data-layout",
|
|
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
|
|
);
|
|
let mut features = "-3dnow,-3dnowa,-mmx,+soft-float".to_string();
|
|
if cfg.has("MITIGATION_RETPOLINE") {
|
|
features += ",+retpoline-external-thunk";
|
|
}
|
|
ts.push("features", features);
|
|
ts.push("llvm-target", "x86_64-linux-gnu");
|
|
ts.push("target-pointer-width", "64");
|
|
} else if cfg.has("LOONGARCH") {
|
|
ts.push("arch", "loongarch64");
|
|
ts.push("data-layout", "e-m:e-p:64:64-i64:64-i128:128-n64-S128");
|
|
ts.push("features", "-f,-d");
|
|
ts.push("llvm-target", "loongarch64-linux-gnusf");
|
|
ts.push("llvm-abiname", "lp64s");
|
|
ts.push("target-pointer-width", "64");
|
|
} else {
|
|
panic!("Unsupported architecture");
|
|
}
|
|
|
|
ts.push("emit-debug-gdb-scripts", false);
|
|
ts.push("frame-pointer", "may-omit");
|
|
ts.push(
|
|
"stack-probes",
|
|
vec![("kind".to_string(), Value::String("none".to_string()))],
|
|
);
|
|
|
|
// Everything else is LE, whether `CPU_LITTLE_ENDIAN` is declared or not
|
|
// (e.g. x86). It is also `rustc`'s default.
|
|
if cfg.has("CPU_BIG_ENDIAN") {
|
|
ts.push("target-endian", "big");
|
|
}
|
|
|
|
println!("{}", ts);
|
|
}
|