diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c index a8bdc865c..c542aa61d 100644 --- a/bin/pax/ar_subs.c +++ b/bin/pax/ar_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar_subs.c,v 1.50 2021/10/24 21:24:21 deraadt Exp $ */ +/* $OpenBSD: ar_subs.c,v 1.51 2023/07/10 16:28:33 jeremy Exp $ */ /* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */ /*- @@ -441,6 +441,23 @@ wr_archive(ARCHD *arcn, int is_app) if (hlk && (chk_lnk(arcn) < 0)) break; + /* + * Modify the name as requested by the user + */ + if ((res = mod_name(arcn)) < 0) { + /* + * pax finished, purge link table entry and stop + */ + purg_lnk(arcn); + break; + } else if (res > 0) { + /* + * skipping file, purge link table entry + */ + purg_lnk(arcn); + continue; + } + if (PAX_IS_REG(arcn->type) || (arcn->type == PAX_HRG)) { /* * we will have to read this file. by opening it now we @@ -456,20 +473,7 @@ wr_archive(ARCHD *arcn, int is_app) } } - /* - * Now modify the name as requested by the user - */ - if ((res = mod_name(arcn)) < 0) { - /* - * name modification says to skip this file, close the - * file and purge link table entry - */ - rdfile_close(arcn, &fd); - purg_lnk(arcn); - break; - } - - if ((res > 0) || (docrc && (set_crc(arcn, fd) < 0))) { + if (docrc && (set_crc(arcn, fd) < 0)) { /* * unable to obtain the crc we need, close the file, * purge link table entry diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index 6f5eb5b7e..d84bedb04 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -1823,6 +1823,7 @@ ./usr/share/man/man3/BN_cmp.3 ./usr/share/man/man3/BN_copy.3 ./usr/share/man/man3/BN_generate_prime.3 +./usr/share/man/man3/BN_get_rfc3526_prime_8192.3 ./usr/share/man/man3/BN_kronecker.3 ./usr/share/man/man3/BN_mod_inverse.3 ./usr/share/man/man3/BN_mod_mul_montgomery.3 @@ -2595,7 +2596,6 @@ ./usr/share/man/man3/gelf_newphdr.3 ./usr/share/man/man3/gelf_update_ehdr.3 ./usr/share/man/man3/gelf_xlatetof.3 -./usr/share/man/man3/get_rfc3526_prime_8192.3 ./usr/share/man/man3/getaddrinfo.3 ./usr/share/man/man3/getbsize.3 ./usr/share/man/man3/getc.3 @@ -3051,6 +3051,8 @@ ./usr/share/man/man3/wscanf.3 ./usr/share/man/man3/xdr.3 ./usr/share/man/man3/yp_bind.3 +./usr/share/man/man4/riscv64/stfpcie.4 +./usr/share/man/man4/riscv64/stfpciephy.4 ./usr/share/man/man9/KASSERT.9 ./usr/share/man/man9/RBT_INIT.9 ./usr/share/man/man9/SMR_LIST_INIT.9 diff --git a/etc/root/root.mail b/etc/root/root.mail index b3b34b432..b75585ac3 100644 --- a/etc/root/root.mail +++ b/etc/root/root.mail @@ -1,6 +1,6 @@ -From purplerain@secbsd.org Thu Jul 6 00:00:00 UTC 2023 +From purplerain@secbsd.org Thu Jul 20 00:00:00 UTC 2023 Return-Path: root -Date: Jul 6 00:00:00 UTC 2023 +Date: Jul 20 00:00:00 UTC 2023 From: purplerain@secbsd.org (Purple Rain) To: root Subject: Welcome to SecBSD 1.3! diff --git a/etc/skel/dot.version b/etc/skel/dot.version index 7b27a965d..d6e3c66ce 100644 --- a/etc/skel/dot.version +++ b/etc/skel/dot.version @@ -1 +1 @@ -# SecBSD 1.3-3c7d048: Thu Jul 6 00:00:00 UTC 2023 (Quetzalcoatl) +# SecBSD 1.3-3be5e12: Thu Jul 20 00:00:00 UTC 2023 (Tezcatlipoca) diff --git a/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp b/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp index ddc77ec45..7d448c0ff 100644 --- a/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp +++ b/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp @@ -1800,7 +1800,10 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, D.Diag(diag::err_invalid_branch_protection) << Scope << A->getAsString(Args); Key = "a_key"; - IndirectBranches = false; + if (Triple.isOSOpenBSD()) + IndirectBranches = true; + else + IndirectBranches = false; } else { StringRef Err; llvm::AArch64::ParsedBranchProtection PBP; diff --git a/gnu/llvm/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp b/gnu/llvm/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp index 16fb38e10..e37fbec9e 100644 --- a/gnu/llvm/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp +++ b/gnu/llvm/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp @@ -813,6 +813,31 @@ static lldb::addr_t ReadLinuxProcessAddressMask(lldb::ProcessSP process_sp, return address_mask; } +// Reads code or data address mask for the current OpenBSD process. +static lldb::addr_t ReadOpenBSDProcessAddressMask(lldb::ProcessSP process_sp, + llvm::StringRef reg_name) { + // We set default value of mask such that no bits are masked out. + uint64_t address_mask = 0ULL; + // If Pointer Authentication feature is enabled then OpenBSD exposes + // PAC data and code mask register. Try reading relevant register + // below and merge it with default address mask calculated above. + lldb::ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread(); + if (thread_sp) { + lldb::RegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext(); + if (reg_ctx_sp) { + const RegisterInfo *reg_info = + reg_ctx_sp->GetRegisterInfoByName(reg_name, 0); + if (reg_info) { + lldb::addr_t mask_reg_val = reg_ctx_sp->ReadRegisterAsUnsigned( + reg_info->kinds[eRegisterKindLLDB], LLDB_INVALID_ADDRESS); + if (mask_reg_val != LLDB_INVALID_ADDRESS) + address_mask |= mask_reg_val; + } + } + } + return address_mask; +} + lldb::addr_t ABISysV_arm64::FixCodeAddress(lldb::addr_t pc) { if (lldb::ProcessSP process_sp = GetProcessSP()) { if (process_sp->GetTarget().GetArchitecture().GetTriple().isOSLinux() && @@ -820,6 +845,11 @@ lldb::addr_t ABISysV_arm64::FixCodeAddress(lldb::addr_t pc) { process_sp->SetCodeAddressMask( ReadLinuxProcessAddressMask(process_sp, "code_mask")); + if (process_sp->GetTarget().GetArchitecture().GetTriple().isOSOpenBSD() && + !process_sp->GetCodeAddressMask()) + process_sp->SetCodeAddressMask( + ReadOpenBSDProcessAddressMask(process_sp, "code_mask")); + return FixAddress(pc, process_sp->GetCodeAddressMask()); } return pc; @@ -832,6 +862,11 @@ lldb::addr_t ABISysV_arm64::FixDataAddress(lldb::addr_t pc) { process_sp->SetDataAddressMask( ReadLinuxProcessAddressMask(process_sp, "data_mask")); + if (process_sp->GetTarget().GetArchitecture().GetTriple().isOSOpenBSD() && + !process_sp->GetDataAddressMask()) + process_sp->SetDataAddressMask( + ReadOpenBSDProcessAddressMask(process_sp, "data_mask")); + return FixAddress(pc, process_sp->GetDataAddressMask()); } return pc; diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp index 8b76bc8ba..7fe177e49 100644 --- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp +++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp @@ -27,6 +27,7 @@ // clang-format off #include +#include #include #include #include @@ -37,77 +38,6 @@ using namespace lldb_private::process_openbsd; #define REG_CONTEXT_SIZE (GetGPRSize() + GetFPRSize()) -// ARM64 general purpose registers. -static const uint32_t g_gpr_regnums_arm64[] = { - gpr_x0_arm64, gpr_x1_arm64, gpr_x2_arm64, gpr_x3_arm64, - gpr_x4_arm64, gpr_x5_arm64, gpr_x6_arm64, gpr_x7_arm64, - gpr_x8_arm64, gpr_x9_arm64, gpr_x10_arm64, gpr_x11_arm64, - gpr_x12_arm64, gpr_x13_arm64, gpr_x14_arm64, gpr_x15_arm64, - gpr_x16_arm64, gpr_x17_arm64, gpr_x18_arm64, gpr_x19_arm64, - gpr_x20_arm64, gpr_x21_arm64, gpr_x22_arm64, gpr_x23_arm64, - gpr_x24_arm64, gpr_x25_arm64, gpr_x26_arm64, gpr_x27_arm64, - gpr_x28_arm64, gpr_fp_arm64, gpr_lr_arm64, gpr_sp_arm64, - gpr_pc_arm64, gpr_cpsr_arm64, gpr_w0_arm64, gpr_w1_arm64, - gpr_w2_arm64, gpr_w3_arm64, gpr_w4_arm64, gpr_w5_arm64, - gpr_w6_arm64, gpr_w7_arm64, gpr_w8_arm64, gpr_w9_arm64, - gpr_w10_arm64, gpr_w11_arm64, gpr_w12_arm64, gpr_w13_arm64, - gpr_w14_arm64, gpr_w15_arm64, gpr_w16_arm64, gpr_w17_arm64, - gpr_w18_arm64, gpr_w19_arm64, gpr_w20_arm64, gpr_w21_arm64, - gpr_w22_arm64, gpr_w23_arm64, gpr_w24_arm64, gpr_w25_arm64, - gpr_w26_arm64, gpr_w27_arm64, gpr_w28_arm64, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; -static_assert(((sizeof g_gpr_regnums_arm64 / sizeof g_gpr_regnums_arm64[0]) - - 1) == k_num_gpr_registers_arm64, - "g_gpr_regnums_arm64 has wrong number of register infos"); - -// ARM64 floating point registers. -static const uint32_t g_fpu_regnums_arm64[] = { - fpu_v0_arm64, fpu_v1_arm64, fpu_v2_arm64, fpu_v3_arm64, - fpu_v4_arm64, fpu_v5_arm64, fpu_v6_arm64, fpu_v7_arm64, - fpu_v8_arm64, fpu_v9_arm64, fpu_v10_arm64, fpu_v11_arm64, - fpu_v12_arm64, fpu_v13_arm64, fpu_v14_arm64, fpu_v15_arm64, - fpu_v16_arm64, fpu_v17_arm64, fpu_v18_arm64, fpu_v19_arm64, - fpu_v20_arm64, fpu_v21_arm64, fpu_v22_arm64, fpu_v23_arm64, - fpu_v24_arm64, fpu_v25_arm64, fpu_v26_arm64, fpu_v27_arm64, - fpu_v28_arm64, fpu_v29_arm64, fpu_v30_arm64, fpu_v31_arm64, - - fpu_s0_arm64, fpu_s1_arm64, fpu_s2_arm64, fpu_s3_arm64, - fpu_s4_arm64, fpu_s5_arm64, fpu_s6_arm64, fpu_s7_arm64, - fpu_s8_arm64, fpu_s9_arm64, fpu_s10_arm64, fpu_s11_arm64, - fpu_s12_arm64, fpu_s13_arm64, fpu_s14_arm64, fpu_s15_arm64, - fpu_s16_arm64, fpu_s17_arm64, fpu_s18_arm64, fpu_s19_arm64, - fpu_s20_arm64, fpu_s21_arm64, fpu_s22_arm64, fpu_s23_arm64, - fpu_s24_arm64, fpu_s25_arm64, fpu_s26_arm64, fpu_s27_arm64, - fpu_s28_arm64, fpu_s29_arm64, fpu_s30_arm64, fpu_s31_arm64, - - fpu_d0_arm64, fpu_d1_arm64, fpu_d2_arm64, fpu_d3_arm64, - fpu_d4_arm64, fpu_d5_arm64, fpu_d6_arm64, fpu_d7_arm64, - fpu_d8_arm64, fpu_d9_arm64, fpu_d10_arm64, fpu_d11_arm64, - fpu_d12_arm64, fpu_d13_arm64, fpu_d14_arm64, fpu_d15_arm64, - fpu_d16_arm64, fpu_d17_arm64, fpu_d18_arm64, fpu_d19_arm64, - fpu_d20_arm64, fpu_d21_arm64, fpu_d22_arm64, fpu_d23_arm64, - fpu_d24_arm64, fpu_d25_arm64, fpu_d26_arm64, fpu_d27_arm64, - fpu_d28_arm64, fpu_d29_arm64, fpu_d30_arm64, fpu_d31_arm64, - fpu_fpsr_arm64, fpu_fpcr_arm64, - LLDB_INVALID_REGNUM // register sets need to end with this flag -}; -static_assert(((sizeof g_fpu_regnums_arm64 / sizeof g_fpu_regnums_arm64[0]) - - 1) == k_num_fpr_registers_arm64, - "g_fpu_regnums_arm64 has wrong number of register infos"); - -namespace { -// Number of register sets provided by this context. -enum { k_num_register_sets = 2 }; -} - -// Register sets for ARM64. -static const RegisterSet g_reg_sets_arm64[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_arm64, - g_gpr_regnums_arm64}, - {"Floating Point Registers", "fpu", k_num_fpr_registers_arm64, - g_fpu_regnums_arm64}}; - std::unique_ptr NativeRegisterContextOpenBSD::CreateHostNativeRegisterContextOpenBSD( const ArchSpec &target_arch, NativeThreadProtocol &native_thread) { @@ -122,7 +52,9 @@ static RegisterInfoInterface * CreateRegisterInfoInterface(const ArchSpec &target_arch) { assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) && "Register setting path assumes this is a 64-bit host"); - return new RegisterInfoPOSIX_arm64(target_arch, 0); + + Flags opt_regsets = RegisterInfoPOSIX_arm64::eRegsetMaskPAuth; + return new RegisterInfoPOSIX_arm64(target_arch, opt_regsets); } static llvm::APInt uint128ToAPInt(__uint128_t in) { @@ -145,23 +77,25 @@ NativeRegisterContextOpenBSD_arm64::NativeRegisterContextOpenBSD_arm64( CreateRegisterInfoInterface(target_arch)), m_gpr(), m_fpr() {} -uint32_t NativeRegisterContextOpenBSD_arm64::GetUserRegisterCount() const { - uint32_t count = 0; - for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) - count += g_reg_sets_arm64[set_index].num_registers; - return count; +RegisterInfoPOSIX_arm64 & +NativeRegisterContextOpenBSD_arm64::GetRegisterInfo() const { + return static_cast(*m_register_info_interface_up); } uint32_t NativeRegisterContextOpenBSD_arm64::GetRegisterSetCount() const { - return k_num_register_sets; + return GetRegisterInfo().GetRegisterSetCount(); } const RegisterSet * NativeRegisterContextOpenBSD_arm64::GetRegisterSet(uint32_t set_index) const { - if (set_index < k_num_register_sets) - return &g_reg_sets_arm64[set_index]; + return GetRegisterInfo().GetRegisterSet(set_index); +} - return nullptr; +uint32_t NativeRegisterContextOpenBSD_arm64::GetUserRegisterCount() const { + uint32_t count = 0; + for (uint32_t set_index = 0; set_index < GetRegisterSetCount(); ++set_index) + count += GetRegisterSet(set_index)->num_registers; + return count; } Status @@ -202,6 +136,18 @@ NativeRegisterContextOpenBSD_arm64::ReadRegister(const RegisterInfo *reg_info, return error; } + if (GetRegisterInfo().IsPAuthReg(reg)) { + uint32_t offset; + + offset = reg_info->byte_offset - GetRegisterInfo().GetPAuthOffset(); + reg_value = (uint64_t)m_pacmask[offset > 0]; + if (reg_value.GetByteSize() > reg_info->byte_size) { + reg_value.SetType(reg_info); + } + + return error; + } + switch (reg) { case gpr_x0_arm64: case gpr_x1_arm64: @@ -527,6 +473,8 @@ int NativeRegisterContextOpenBSD_arm64::GetSetForNativeRegNum( return GPRegSet; else if (reg_num >= k_first_fpr_arm64 && reg_num <= k_last_fpr_arm64) return FPRegSet; + else if (GetRegisterInfo().IsPAuthReg(reg_num)) + return PACMaskRegSet; else return -1; } @@ -539,6 +487,9 @@ int NativeRegisterContextOpenBSD_arm64::ReadRegisterSet(uint32_t set) { case FPRegSet: ReadFPR(); return 0; + case PACMaskRegSet: + ReadPACMask(); + return 0; default: break; } @@ -558,4 +509,16 @@ int NativeRegisterContextOpenBSD_arm64::WriteRegisterSet(uint32_t set) { } return -1; } + +Status NativeRegisterContextOpenBSD_arm64::ReadPACMask() { +#ifdef PT_PACMASK + return NativeProcessOpenBSD::PtraceWrapper(PT_PACMASK, GetProcessPid(), + &m_pacmask, sizeof(m_pacmask)); +#else + Status error; + ::memset(&m_pacmask, 0, sizeof(m_pacmask)); + return error; +#endif +} + #endif diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h index 7cab092bd..106d1b610 100644 --- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h +++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h @@ -16,6 +16,7 @@ // clang-format on #include "Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD.h" +#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h" #include "Plugins/Process/Utility/lldb-arm64-register-enums.h" namespace lldb_private { @@ -65,16 +66,21 @@ protected: private: // Private member types. - enum { GPRegSet, FPRegSet }; + enum { GPRegSet, FPRegSet, PACMaskRegSet }; // Private member variables. struct reg m_gpr; struct fpreg m_fpr; + register_t m_pacmask[2]; int GetSetForNativeRegNum(int reg_num) const; int ReadRegisterSet(uint32_t set); int WriteRegisterSet(uint32_t set); + + RegisterInfoPOSIX_arm64 &GetRegisterInfo() const; + + Status ReadPACMask(); }; } // namespace process_openbsd diff --git a/gnu/llvm/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h b/gnu/llvm/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h index f6a2fbdcc..f911bddb7 100644 --- a/gnu/llvm/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h +++ b/gnu/llvm/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h @@ -67,6 +67,7 @@ enum { NT_AUXV = 11, NT_REGS = 20, NT_FPREGS = 21, + NT_PACMASK = 24, }; } @@ -121,6 +122,7 @@ constexpr RegsetDesc AARCH64_SVE_Desc[] = { constexpr RegsetDesc AARCH64_PAC_Desc[] = { {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_PAC_MASK}, + {llvm::Triple::OpenBSD, llvm::Triple::aarch64, OPENBSD::NT_PACMASK}, }; constexpr RegsetDesc PPC_VMX_Desc[] = { diff --git a/lib/libc/stdio/open_memstream.c b/lib/libc/stdio/open_memstream.c index 7b063e374..af0169f67 100644 --- a/lib/libc/stdio/open_memstream.c +++ b/lib/libc/stdio/open_memstream.c @@ -1,4 +1,4 @@ -/* $OpenBSD: open_memstream.c,v 1.9 2023/06/21 13:11:49 claudio Exp $ */ +/* $OpenBSD: open_memstream.c,v 1.10 2023/07/11 12:14:16 claudio Exp $ */ /* * Copyright (c) 2011 Martin Pieuchot @@ -135,7 +135,6 @@ open_memstream(char **pbuf, size_t *psize) return (NULL); } - *st->string = '\0'; st->pos = 0; st->len = 0; st->pbuf = pbuf; diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c index 01dd78276..fca0b7138 100644 --- a/lib/libc/stdio/open_wmemstream.c +++ b/lib/libc/stdio/open_wmemstream.c @@ -1,4 +1,4 @@ -/* $OpenBSD: open_wmemstream.c,v 1.9 2023/06/21 13:11:49 claudio Exp $ */ +/* $OpenBSD: open_wmemstream.c,v 1.10 2023/07/11 12:14:16 claudio Exp $ */ /* * Copyright (c) 2011 Martin Pieuchot @@ -145,7 +145,6 @@ open_wmemstream(wchar_t **pbuf, size_t *psize) return (NULL); } - *st->string = L'\0'; st->pos = 0; st->len = 0; st->pbuf = pbuf; diff --git a/lib/libc/sys/poll.2 b/lib/libc/sys/poll.2 index ec0b2881e..c8e03f29e 100644 --- a/lib/libc/sys/poll.2 +++ b/lib/libc/sys/poll.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: poll.2,v 1.39 2022/01/21 15:23:36 millert Exp $ +.\" $OpenBSD: poll.2,v 1.40 2023/07/18 04:17:17 asou Exp $ .\" .\" Copyright (c) 1994 Jason R. Thorpe .\" All rights reserved. @@ -28,7 +28,7 @@ .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" -.Dd $Mdocdate: January 21 2022 $ +.Dd $Mdocdate: July 18 2023 $ .Dt POLL 2 .Os .Sh NAME @@ -287,9 +287,9 @@ if (nready == -1) err(1, "poll"); if (nready == 0) errx(1, "time out"); -if ((pfd[0].revents & (POLLERR|POLLNVAL))) +if (pfd[0].revents & (POLLERR|POLLNVAL)) errx(1, "bad fd %d", pfd[0].fd); -if ((pfd[0].revents & (POLLIN|POLLHUP))) { +if (pfd[0].revents & (POLLIN|POLLHUP)) { if (read(STDIN_FILENO, buf, sizeof(buf)) == -1) err(1, "read"); } diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile index 44e590086..8ec9b1b3d 100644 --- a/lib/libcrypto/Makefile +++ b/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.137 2023/07/07 06:10:14 jsing Exp $ +# $OpenBSD: Makefile,v 1.138 2023/07/20 16:36:06 tb Exp $ LIB= crypto LIBREBUILD=y @@ -386,8 +386,6 @@ SRCS+= tb_pkmeth.c SRCS+= tb_rand.c SRCS+= tb_rsa.c SRCS+= tb_store.c -# XXX unnecessary? handled in EVP now... -# SRCS+= eng_aesni.c # local addition # err/ SRCS+= err.c diff --git a/lib/libcrypto/asn1/asn1_item.c b/lib/libcrypto/asn1/asn1_item.c index 4458ceb86..87f426c6f 100644 --- a/lib/libcrypto/asn1/asn1_item.c +++ b/lib/libcrypto/asn1/asn1_item.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_item.c,v 1.16 2023/07/07 19:37:52 beck Exp $ */ +/* $OpenBSD: asn1_item.c,v 1.17 2023/07/13 20:59:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -230,73 +230,59 @@ ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, &ctx); } -int -ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, - ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx) +static int +asn1_item_set_algorithm_identifiers(EVP_MD_CTX *ctx, X509_ALGOR *algor1, + X509_ALGOR *algor2) { - const EVP_MD *type; EVP_PKEY *pkey; - unsigned char *in = NULL, *out = NULL; - size_t out_len = 0; - int in_len = 0; - int signid, paramtype; - int rv = 2; - int ret = 0; + ASN1_OBJECT *aobj; + const EVP_MD *md; + int sign_id, sign_param; if ((pkey = EVP_PKEY_CTX_get0_pkey(ctx->pctx)) == NULL) { ASN1error(ASN1_R_CONTEXT_NOT_INITIALISED); return 0; } - if (pkey->ameth == NULL) { - ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); + if ((md = EVP_MD_CTX_md(ctx)) == NULL) { + ASN1error(ASN1_R_CONTEXT_NOT_INITIALISED); return 0; } - if (pkey->ameth->item_sign != NULL) { - rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2, - signature); - if (rv == 1) { - out_len = signature->length; - goto done; - } - /* Return value meanings: - * <=0: error. - * 1: method does everything. - * 2: carry on as normal. - * 3: ASN1 method sets algorithm identifiers: just sign. - */ - if (rv <= 0) { - ASN1error(ERR_R_EVP_LIB); - goto err; - } + if (!OBJ_find_sigid_by_algs(&sign_id, EVP_MD_nid(md), + pkey->ameth->pkey_id)) { + ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); + return 0; + } + if ((aobj = OBJ_nid2obj(sign_id)) == NULL) { + ASN1error(ASN1_R_UNKNOWN_OBJECT_TYPE); + return 0; } - if (rv == 2) { - if ((type = EVP_MD_CTX_md(ctx)) == NULL) { - ASN1error(ASN1_R_CONTEXT_NOT_INITIALISED); + sign_param = V_ASN1_UNDEF; + if (pkey->ameth->pkey_flags & ASN1_PKEY_SIGPARAM_NULL) + sign_param = V_ASN1_NULL; + + if (algor1 != NULL) { + if (!X509_ALGOR_set0(algor1, aobj, sign_param, NULL)) return 0; - } - - if (!OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type), - pkey->ameth->pkey_id)) { - ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); - return 0; - } - - if (pkey->ameth->pkey_flags & ASN1_PKEY_SIGPARAM_NULL) - paramtype = V_ASN1_NULL; - else - paramtype = V_ASN1_UNDEF; - - if (algor1) - X509_ALGOR_set0(algor1, - OBJ_nid2obj(signid), paramtype, NULL); - if (algor2) - X509_ALGOR_set0(algor2, - OBJ_nid2obj(signid), paramtype, NULL); - } + if (algor2 != NULL) { + if (!X509_ALGOR_set0(algor2, aobj, sign_param, NULL)) + return 0; + } + + return 1; +} + +static int +asn1_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, + ASN1_BIT_STRING *signature) +{ + unsigned char *in = NULL, *out = NULL; + size_t out_len = 0; + int in_len = 0; + int ret = 0; if ((in_len = ASN1_item_i2d(asn, &in, it)) <= 0) { in_len = 0; @@ -325,20 +311,69 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, out = NULL; if (!asn1_abs_set_unused_bits(signature, 0)) { + ASN1_STRING_set0(signature, NULL, 0); ASN1error(ERR_R_ASN1_LIB); goto err; } - done: - ret = out_len; + ret = 1; + err: - EVP_MD_CTX_cleanup(ctx); freezero(in, in_len); freezero(out, out_len); return ret; } +int +ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx) +{ + EVP_PKEY *pkey; + int rv; + int ret = 0; + + if ((pkey = EVP_PKEY_CTX_get0_pkey(ctx->pctx)) == NULL) { + ASN1error(ASN1_R_CONTEXT_NOT_INITIALISED); + goto err; + } + if (pkey->ameth == NULL) { + ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); + goto err; + } + + /* + * API insanity ahead. If the item_sign() method is absent or if it + * returns 2, this means: do all the work here. If it returns 3, only + * sign. If it returns 1, then there's nothing to do but to return + * the signature's length. Everything else is an error. + */ + + rv = 2; + if (pkey->ameth->item_sign != NULL) + rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2, + signature); + if (rv <= 0 || rv > 3) + goto err; + if (rv == 1) + goto done; + if (rv == 2) { + if (!asn1_item_set_algorithm_identifiers(ctx, algor1, algor2)) + goto err; + } + + if (!asn1_item_sign(ctx, it, asn, signature)) + goto err; + + done: + ret = signature->length; + + err: + EVP_MD_CTX_cleanup(ctx); + + return ret; +} + int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey) diff --git a/lib/libcrypto/asn1/bio_ndef.c b/lib/libcrypto/asn1/bio_ndef.c index d0329ede8..11e51edad 100644 --- a/lib/libcrypto/asn1/bio_ndef.c +++ b/lib/libcrypto/asn1/bio_ndef.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ndef.c,v 1.22 2023/04/25 19:08:30 tb Exp $ */ +/* $OpenBSD: bio_ndef.c,v 1.23 2023/07/09 19:22:43 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -171,7 +171,7 @@ static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg) { NDEF_SUPPORT *ndef_aux; - unsigned char *p; + unsigned char *p = NULL; int derlen; if (!parg) @@ -179,13 +179,13 @@ ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg) ndef_aux = *(NDEF_SUPPORT **)parg; - derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); - p = malloc(derlen); + if ((derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it)) <= 0) + return 0; + ndef_aux->derbuf = p; *pbuf = p; - derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); - if (!*ndef_aux->boundary) + if (*ndef_aux->boundary == NULL) return 0; *plen = *ndef_aux->boundary - *pbuf; @@ -231,7 +231,7 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg) { NDEF_SUPPORT *ndef_aux; - unsigned char *p; + unsigned char *p = NULL; int derlen; const ASN1_AUX *aux; ASN1_STREAM_ARG sarg; @@ -251,14 +251,15 @@ ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg) &ndef_aux->val, ndef_aux->it, &sarg) <= 0) return 0; - derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); - p = malloc(derlen); + if ((derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it)) <= 0) + return 0; + ndef_aux->derbuf = p; *pbuf = p; - derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); - if (!*ndef_aux->boundary) + if (*ndef_aux->boundary == NULL) return 0; + *pbuf = *ndef_aux->boundary; *plen = derlen - (*ndef_aux->boundary - ndef_aux->derbuf); diff --git a/lib/libcrypto/bio/bio_lib.c b/lib/libcrypto/bio/bio_lib.c index 3dd5e17ed..c0a74ee29 100644 --- a/lib/libcrypto/bio/bio_lib.c +++ b/lib/libcrypto/bio/bio_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_lib.c,v 1.46 2023/07/07 19:37:53 beck Exp $ */ +/* $OpenBSD: bio_lib.c,v 1.47 2023/07/10 02:33:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -548,11 +548,10 @@ BIO_indent(BIO *b, int indent, int max) { if (indent > max) indent = max; - if (indent < 0) - indent = 0; - while (indent--) - if (BIO_puts(b, " ") != 1) - return 0; + if (indent <= 0) + return 1; + if (BIO_printf(b, "%*s", indent, "") <= 0) + return 0; return 1; } LCRYPTO_ALIAS(BIO_indent); diff --git a/lib/libcrypto/bn/bn_const.c b/lib/libcrypto/bn/bn_const.c index e0009b0be..b204eb0bc 100644 --- a/lib/libcrypto/bn/bn_const.c +++ b/lib/libcrypto/bn/bn_const.c @@ -1,9 +1,10 @@ -/* $OpenBSD: bn_const.c,v 1.6 2023/07/08 12:21:58 beck Exp $ */ +/* $OpenBSD: bn_const.c,v 1.7 2023/07/10 03:26:30 tb Exp $ */ /* Insert boilerplate */ #include -/* "First Oakley Default Group" from RFC2409, section 6.1. +/* + * "First Oakley Default Group" from RFC2409, section 6.1. * * The prime is: 2^768 - 2 ^704 - 1 + 2^64 * { [2^638 pi] + 149686 } * @@ -11,19 +12,20 @@ * RFC2412 specifies a generator of of 22. */ +static const unsigned char RFC2409_PRIME_768[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x3A, 0x36, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc2409_prime_768(BIGNUM *bn) { - static const unsigned char RFC2409_PRIME_768[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x3A, 0x36, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC2409_PRIME_768, sizeof(RFC2409_PRIME_768), bn); } LCRYPTO_ALIAS(get_rfc2409_prime_768); @@ -31,11 +33,12 @@ LCRYPTO_ALIAS(get_rfc2409_prime_768); BIGNUM * BN_get_rfc2409_prime_768(BIGNUM *bn) { - return get_rfc2409_prime_768(bn); + return BN_bin2bn(RFC2409_PRIME_768, sizeof(RFC2409_PRIME_768), bn); } LCRYPTO_ALIAS(BN_get_rfc2409_prime_768); -/* "Second Oakley Default Group" from RFC2409, section 6.2. +/* + * "Second Oakley Default Group" from RFC2409, section 6.2. * * The prime is: 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 }. * @@ -43,22 +46,23 @@ LCRYPTO_ALIAS(BN_get_rfc2409_prime_768); * RFC2412 specifies a generator of 22. */ +static const unsigned char RFC2409_PRIME_1024[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, + 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, + 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc2409_prime_1024(BIGNUM *bn) { - static const unsigned char RFC2409_PRIME_1024[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, - 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC2409_PRIME_1024, sizeof(RFC2409_PRIME_1024), bn); } LCRYPTO_ALIAS(get_rfc2409_prime_1024); @@ -66,11 +70,12 @@ LCRYPTO_ALIAS(get_rfc2409_prime_1024); BIGNUM * BN_get_rfc2409_prime_1024(BIGNUM *bn) { - return get_rfc2409_prime_1024(bn); + return BN_bin2bn(RFC2409_PRIME_1024, sizeof(RFC2409_PRIME_1024), bn); } LCRYPTO_ALIAS(BN_get_rfc2409_prime_1024); -/* "1536-bit MODP Group" from RFC3526, Section 2. +/* + * "1536-bit MODP Group" from RFC3526, Section 2. * * The prime is: 2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 } * @@ -78,27 +83,28 @@ LCRYPTO_ALIAS(BN_get_rfc2409_prime_1024); * RFC2312 specifies a generator of 22. */ +static const unsigned char RFC3526_PRIME_1536[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, + 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, + 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, + 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, + 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, + 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, + 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, + 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, + 0xCA, 0x23, 0x73, 0x27, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc3526_prime_1536(BIGNUM *bn) { - static const unsigned char RFC3526_PRIME_1536[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, - 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, - 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, - 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, - 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, - 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, - 0xCA, 0x23, 0x73, 0x27, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC3526_PRIME_1536, sizeof(RFC3526_PRIME_1536), bn); } LCRYPTO_ALIAS(get_rfc3526_prime_1536); @@ -106,44 +112,46 @@ LCRYPTO_ALIAS(get_rfc3526_prime_1536); BIGNUM * BN_get_rfc3526_prime_1536(BIGNUM *bn) { - return get_rfc3526_prime_1536(bn); + return BN_bin2bn(RFC3526_PRIME_1536, sizeof(RFC3526_PRIME_1536), bn); } LCRYPTO_ALIAS(BN_get_rfc3526_prime_1536); -/* "2048-bit MODP Group" from RFC3526, Section 3. +/* + * "2048-bit MODP Group" from RFC3526, Section 3. * * The prime is: 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 } * * RFC3526 specifies a generator of 2. */ +static const unsigned char RFC3526_PRIME_2048[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, + 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, + 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, + 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, + 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, + 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, + 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, + 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, + 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, + 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, + 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, + 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, + 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, + 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc3526_prime_2048(BIGNUM *bn) { - static const unsigned char RFC3526_PRIME_2048[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, - 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, - 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, - 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, - 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, - 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, - 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, - 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, - 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, - 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC3526_PRIME_2048, sizeof(RFC3526_PRIME_2048), bn); } LCRYPTO_ALIAS(get_rfc3526_prime_2048); @@ -151,54 +159,56 @@ LCRYPTO_ALIAS(get_rfc3526_prime_2048); BIGNUM * BN_get_rfc3526_prime_2048(BIGNUM *bn) { - return get_rfc3526_prime_2048(bn); + return BN_bin2bn(RFC3526_PRIME_2048, sizeof(RFC3526_PRIME_2048), bn); } LCRYPTO_ALIAS(BN_get_rfc3526_prime_2048); -/* "3072-bit MODP Group" from RFC3526, Section 4. +/* + * "3072-bit MODP Group" from RFC3526, Section 4. * * The prime is: 2^3072 - 2^3008 - 1 + 2^64 * { [2^2942 pi] + 1690314 } * * RFC3526 specifies a generator of 2. */ +static const unsigned char RFC3526_PRIME_3072[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, + 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, + 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, + 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, + 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, + 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, + 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, + 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, + 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, + 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, + 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, + 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, + 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, + 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, + 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, + 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, + 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, + 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, + 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, + 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, + 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, + 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, + 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, + 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, + 0xA9, 0x3A, 0xD2, 0xCA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc3526_prime_3072(BIGNUM *bn) { - static const unsigned char RFC3526_PRIME_3072[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, - 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, - 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, - 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, - 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, - 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, - 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, - 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, - 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, - 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, - 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, - 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, - 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, - 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, - 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, - 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, - 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, - 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, - 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, - 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, - 0xA9, 0x3A, 0xD2, 0xCA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC3526_PRIME_3072, sizeof(RFC3526_PRIME_3072), bn); } LCRYPTO_ALIAS(get_rfc3526_prime_3072); @@ -206,65 +216,67 @@ LCRYPTO_ALIAS(get_rfc3526_prime_3072); BIGNUM * BN_get_rfc3526_prime_3072(BIGNUM *bn) { - return get_rfc3526_prime_3072(bn); + return BN_bin2bn(RFC3526_PRIME_3072, sizeof(RFC3526_PRIME_3072), bn); } LCRYPTO_ALIAS(BN_get_rfc3526_prime_3072); -/* "4096-bit MODP Group" from RFC3526, Section 5. +/* + * "4096-bit MODP Group" from RFC3526, Section 5. * * The prime is: 2^4096 - 2^4032 - 1 + 2^64 * { [2^3966 pi] + 240904 } * * RFC3526 specifies a generator of 2. */ +static const unsigned char RFC3526_PRIME_4096[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, + 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, + 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, + 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, + 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, + 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, + 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, + 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, + 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, + 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, + 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, + 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, + 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, + 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, + 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, + 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, + 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, + 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, + 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, + 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, + 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, + 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, + 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, + 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, + 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, + 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, + 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, + 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, + 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, + 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, + 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, + 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, + 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, + 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, + 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x06, 0x31, 0x99, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc3526_prime_4096(BIGNUM *bn) { - static const unsigned char RFC3526_PRIME_4096[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, - 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, - 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, - 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, - 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, - 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, - 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, - 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, - 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, - 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, - 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, - 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, - 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, - 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, - 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, - 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, - 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, - 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, - 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, - 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, - 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, - 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, - 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, - 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, - 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, - 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, - 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, - 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, - 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, - 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, - 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x06, 0x31, 0x99, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC3526_PRIME_4096, sizeof(RFC3526_PRIME_4096), bn); } LCRYPTO_ALIAS(get_rfc3526_prime_4096); @@ -272,86 +284,88 @@ LCRYPTO_ALIAS(get_rfc3526_prime_4096); BIGNUM * BN_get_rfc3526_prime_4096(BIGNUM *bn) { - return get_rfc3526_prime_4096(bn); + return BN_bin2bn(RFC3526_PRIME_4096, sizeof(RFC3526_PRIME_4096), bn); } LCRYPTO_ALIAS(BN_get_rfc3526_prime_4096); -/* "6144-bit MODP Group" from RFC3526, Section 6. +/* + * "6144-bit MODP Group" from RFC3526, Section 6. * * The prime is: 2^6144 - 2^6080 - 1 + 2^64 * { [2^6014 pi] + 929484 } * * RFC3526 specifies a generator of 2. */ +static const unsigned char RFC3526_PRIME_6144[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, + 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, + 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, + 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, + 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, + 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, + 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, + 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, + 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, + 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, + 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, + 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, + 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, + 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, + 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, + 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, + 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, + 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, + 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, + 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, + 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, + 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, + 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, + 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, + 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, + 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, + 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, + 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, + 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, + 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, + 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, + 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, + 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, + 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, + 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x02, 0x84, 0x92, + 0x36, 0xC3, 0xFA, 0xB4, 0xD2, 0x7C, 0x70, 0x26, 0xC1, 0xD4, 0xDC, 0xB2, + 0x60, 0x26, 0x46, 0xDE, 0xC9, 0x75, 0x1E, 0x76, 0x3D, 0xBA, 0x37, 0xBD, + 0xF8, 0xFF, 0x94, 0x06, 0xAD, 0x9E, 0x53, 0x0E, 0xE5, 0xDB, 0x38, 0x2F, + 0x41, 0x30, 0x01, 0xAE, 0xB0, 0x6A, 0x53, 0xED, 0x90, 0x27, 0xD8, 0x31, + 0x17, 0x97, 0x27, 0xB0, 0x86, 0x5A, 0x89, 0x18, 0xDA, 0x3E, 0xDB, 0xEB, + 0xCF, 0x9B, 0x14, 0xED, 0x44, 0xCE, 0x6C, 0xBA, 0xCE, 0xD4, 0xBB, 0x1B, + 0xDB, 0x7F, 0x14, 0x47, 0xE6, 0xCC, 0x25, 0x4B, 0x33, 0x20, 0x51, 0x51, + 0x2B, 0xD7, 0xAF, 0x42, 0x6F, 0xB8, 0xF4, 0x01, 0x37, 0x8C, 0xD2, 0xBF, + 0x59, 0x83, 0xCA, 0x01, 0xC6, 0x4B, 0x92, 0xEC, 0xF0, 0x32, 0xEA, 0x15, + 0xD1, 0x72, 0x1D, 0x03, 0xF4, 0x82, 0xD7, 0xCE, 0x6E, 0x74, 0xFE, 0xF6, + 0xD5, 0x5E, 0x70, 0x2F, 0x46, 0x98, 0x0C, 0x82, 0xB5, 0xA8, 0x40, 0x31, + 0x90, 0x0B, 0x1C, 0x9E, 0x59, 0xE7, 0xC9, 0x7F, 0xBE, 0xC7, 0xE8, 0xF3, + 0x23, 0xA9, 0x7A, 0x7E, 0x36, 0xCC, 0x88, 0xBE, 0x0F, 0x1D, 0x45, 0xB7, + 0xFF, 0x58, 0x5A, 0xC5, 0x4B, 0xD4, 0x07, 0xB2, 0x2B, 0x41, 0x54, 0xAA, + 0xCC, 0x8F, 0x6D, 0x7E, 0xBF, 0x48, 0xE1, 0xD8, 0x14, 0xCC, 0x5E, 0xD2, + 0x0F, 0x80, 0x37, 0xE0, 0xA7, 0x97, 0x15, 0xEE, 0xF2, 0x9B, 0xE3, 0x28, + 0x06, 0xA1, 0xD5, 0x8B, 0xB7, 0xC5, 0xDA, 0x76, 0xF5, 0x50, 0xAA, 0x3D, + 0x8A, 0x1F, 0xBF, 0xF0, 0xEB, 0x19, 0xCC, 0xB1, 0xA3, 0x13, 0xD5, 0x5C, + 0xDA, 0x56, 0xC9, 0xEC, 0x2E, 0xF2, 0x96, 0x32, 0x38, 0x7F, 0xE8, 0xD7, + 0x6E, 0x3C, 0x04, 0x68, 0x04, 0x3E, 0x8F, 0x66, 0x3F, 0x48, 0x60, 0xEE, + 0x12, 0xBF, 0x2D, 0x5B, 0x0B, 0x74, 0x74, 0xD6, 0xE6, 0x94, 0xF9, 0x1E, + 0x6D, 0xCC, 0x40, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc3526_prime_6144(BIGNUM *bn) { - static const unsigned char RFC3526_PRIME_6144[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, - 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, - 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, - 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, - 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, - 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, - 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, - 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, - 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, - 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, - 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, - 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, - 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, - 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, - 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, - 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, - 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, - 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, - 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, - 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, - 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, - 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, - 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, - 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, - 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, - 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, - 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, - 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, - 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, - 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, - 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x02, 0x84, 0x92, - 0x36, 0xC3, 0xFA, 0xB4, 0xD2, 0x7C, 0x70, 0x26, 0xC1, 0xD4, 0xDC, 0xB2, - 0x60, 0x26, 0x46, 0xDE, 0xC9, 0x75, 0x1E, 0x76, 0x3D, 0xBA, 0x37, 0xBD, - 0xF8, 0xFF, 0x94, 0x06, 0xAD, 0x9E, 0x53, 0x0E, 0xE5, 0xDB, 0x38, 0x2F, - 0x41, 0x30, 0x01, 0xAE, 0xB0, 0x6A, 0x53, 0xED, 0x90, 0x27, 0xD8, 0x31, - 0x17, 0x97, 0x27, 0xB0, 0x86, 0x5A, 0x89, 0x18, 0xDA, 0x3E, 0xDB, 0xEB, - 0xCF, 0x9B, 0x14, 0xED, 0x44, 0xCE, 0x6C, 0xBA, 0xCE, 0xD4, 0xBB, 0x1B, - 0xDB, 0x7F, 0x14, 0x47, 0xE6, 0xCC, 0x25, 0x4B, 0x33, 0x20, 0x51, 0x51, - 0x2B, 0xD7, 0xAF, 0x42, 0x6F, 0xB8, 0xF4, 0x01, 0x37, 0x8C, 0xD2, 0xBF, - 0x59, 0x83, 0xCA, 0x01, 0xC6, 0x4B, 0x92, 0xEC, 0xF0, 0x32, 0xEA, 0x15, - 0xD1, 0x72, 0x1D, 0x03, 0xF4, 0x82, 0xD7, 0xCE, 0x6E, 0x74, 0xFE, 0xF6, - 0xD5, 0x5E, 0x70, 0x2F, 0x46, 0x98, 0x0C, 0x82, 0xB5, 0xA8, 0x40, 0x31, - 0x90, 0x0B, 0x1C, 0x9E, 0x59, 0xE7, 0xC9, 0x7F, 0xBE, 0xC7, 0xE8, 0xF3, - 0x23, 0xA9, 0x7A, 0x7E, 0x36, 0xCC, 0x88, 0xBE, 0x0F, 0x1D, 0x45, 0xB7, - 0xFF, 0x58, 0x5A, 0xC5, 0x4B, 0xD4, 0x07, 0xB2, 0x2B, 0x41, 0x54, 0xAA, - 0xCC, 0x8F, 0x6D, 0x7E, 0xBF, 0x48, 0xE1, 0xD8, 0x14, 0xCC, 0x5E, 0xD2, - 0x0F, 0x80, 0x37, 0xE0, 0xA7, 0x97, 0x15, 0xEE, 0xF2, 0x9B, 0xE3, 0x28, - 0x06, 0xA1, 0xD5, 0x8B, 0xB7, 0xC5, 0xDA, 0x76, 0xF5, 0x50, 0xAA, 0x3D, - 0x8A, 0x1F, 0xBF, 0xF0, 0xEB, 0x19, 0xCC, 0xB1, 0xA3, 0x13, 0xD5, 0x5C, - 0xDA, 0x56, 0xC9, 0xEC, 0x2E, 0xF2, 0x96, 0x32, 0x38, 0x7F, 0xE8, 0xD7, - 0x6E, 0x3C, 0x04, 0x68, 0x04, 0x3E, 0x8F, 0x66, 0x3F, 0x48, 0x60, 0xEE, - 0x12, 0xBF, 0x2D, 0x5B, 0x0B, 0x74, 0x74, 0xD6, 0xE6, 0x94, 0xF9, 0x1E, - 0x6D, 0xCC, 0x40, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC3526_PRIME_6144, sizeof(RFC3526_PRIME_6144), bn); } LCRYPTO_ALIAS(get_rfc3526_prime_6144); @@ -359,108 +373,110 @@ LCRYPTO_ALIAS(get_rfc3526_prime_6144); BIGNUM * BN_get_rfc3526_prime_6144(BIGNUM *bn) { - return get_rfc3526_prime_6144(bn); + return BN_bin2bn(RFC3526_PRIME_6144, sizeof(RFC3526_PRIME_6144), bn); } LCRYPTO_ALIAS(BN_get_rfc3526_prime_6144); -/* "8192-bit MODP Group" from RFC3526, Section 7. +/* + * "8192-bit MODP Group" from RFC3526, Section 7. * * The prime is: 2^8192 - 2^8128 - 1 + 2^64 * { [2^8062 pi] + 4743158 } * * RFC3526 specifies a generator of 2. */ +static const unsigned char RFC3526_PRIME_8192[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, + 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, + 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, + 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, + 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, + 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, + 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, + 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, + 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, + 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, + 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, + 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, + 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, + 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, + 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, + 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, + 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, + 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, + 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, + 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, + 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, + 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, + 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, + 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, + 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, + 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, + 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, + 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, + 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, + 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, + 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, + 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, + 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, + 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, + 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, + 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, + 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, + 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, + 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, + 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, + 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, + 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x02, 0x84, 0x92, + 0x36, 0xC3, 0xFA, 0xB4, 0xD2, 0x7C, 0x70, 0x26, 0xC1, 0xD4, 0xDC, 0xB2, + 0x60, 0x26, 0x46, 0xDE, 0xC9, 0x75, 0x1E, 0x76, 0x3D, 0xBA, 0x37, 0xBD, + 0xF8, 0xFF, 0x94, 0x06, 0xAD, 0x9E, 0x53, 0x0E, 0xE5, 0xDB, 0x38, 0x2F, + 0x41, 0x30, 0x01, 0xAE, 0xB0, 0x6A, 0x53, 0xED, 0x90, 0x27, 0xD8, 0x31, + 0x17, 0x97, 0x27, 0xB0, 0x86, 0x5A, 0x89, 0x18, 0xDA, 0x3E, 0xDB, 0xEB, + 0xCF, 0x9B, 0x14, 0xED, 0x44, 0xCE, 0x6C, 0xBA, 0xCE, 0xD4, 0xBB, 0x1B, + 0xDB, 0x7F, 0x14, 0x47, 0xE6, 0xCC, 0x25, 0x4B, 0x33, 0x20, 0x51, 0x51, + 0x2B, 0xD7, 0xAF, 0x42, 0x6F, 0xB8, 0xF4, 0x01, 0x37, 0x8C, 0xD2, 0xBF, + 0x59, 0x83, 0xCA, 0x01, 0xC6, 0x4B, 0x92, 0xEC, 0xF0, 0x32, 0xEA, 0x15, + 0xD1, 0x72, 0x1D, 0x03, 0xF4, 0x82, 0xD7, 0xCE, 0x6E, 0x74, 0xFE, 0xF6, + 0xD5, 0x5E, 0x70, 0x2F, 0x46, 0x98, 0x0C, 0x82, 0xB5, 0xA8, 0x40, 0x31, + 0x90, 0x0B, 0x1C, 0x9E, 0x59, 0xE7, 0xC9, 0x7F, 0xBE, 0xC7, 0xE8, 0xF3, + 0x23, 0xA9, 0x7A, 0x7E, 0x36, 0xCC, 0x88, 0xBE, 0x0F, 0x1D, 0x45, 0xB7, + 0xFF, 0x58, 0x5A, 0xC5, 0x4B, 0xD4, 0x07, 0xB2, 0x2B, 0x41, 0x54, 0xAA, + 0xCC, 0x8F, 0x6D, 0x7E, 0xBF, 0x48, 0xE1, 0xD8, 0x14, 0xCC, 0x5E, 0xD2, + 0x0F, 0x80, 0x37, 0xE0, 0xA7, 0x97, 0x15, 0xEE, 0xF2, 0x9B, 0xE3, 0x28, + 0x06, 0xA1, 0xD5, 0x8B, 0xB7, 0xC5, 0xDA, 0x76, 0xF5, 0x50, 0xAA, 0x3D, + 0x8A, 0x1F, 0xBF, 0xF0, 0xEB, 0x19, 0xCC, 0xB1, 0xA3, 0x13, 0xD5, 0x5C, + 0xDA, 0x56, 0xC9, 0xEC, 0x2E, 0xF2, 0x96, 0x32, 0x38, 0x7F, 0xE8, 0xD7, + 0x6E, 0x3C, 0x04, 0x68, 0x04, 0x3E, 0x8F, 0x66, 0x3F, 0x48, 0x60, 0xEE, + 0x12, 0xBF, 0x2D, 0x5B, 0x0B, 0x74, 0x74, 0xD6, 0xE6, 0x94, 0xF9, 0x1E, + 0x6D, 0xBE, 0x11, 0x59, 0x74, 0xA3, 0x92, 0x6F, 0x12, 0xFE, 0xE5, 0xE4, + 0x38, 0x77, 0x7C, 0xB6, 0xA9, 0x32, 0xDF, 0x8C, 0xD8, 0xBE, 0xC4, 0xD0, + 0x73, 0xB9, 0x31, 0xBA, 0x3B, 0xC8, 0x32, 0xB6, 0x8D, 0x9D, 0xD3, 0x00, + 0x74, 0x1F, 0xA7, 0xBF, 0x8A, 0xFC, 0x47, 0xED, 0x25, 0x76, 0xF6, 0x93, + 0x6B, 0xA4, 0x24, 0x66, 0x3A, 0xAB, 0x63, 0x9C, 0x5A, 0xE4, 0xF5, 0x68, + 0x34, 0x23, 0xB4, 0x74, 0x2B, 0xF1, 0xC9, 0x78, 0x23, 0x8F, 0x16, 0xCB, + 0xE3, 0x9D, 0x65, 0x2D, 0xE3, 0xFD, 0xB8, 0xBE, 0xFC, 0x84, 0x8A, 0xD9, + 0x22, 0x22, 0x2E, 0x04, 0xA4, 0x03, 0x7C, 0x07, 0x13, 0xEB, 0x57, 0xA8, + 0x1A, 0x23, 0xF0, 0xC7, 0x34, 0x73, 0xFC, 0x64, 0x6C, 0xEA, 0x30, 0x6B, + 0x4B, 0xCB, 0xC8, 0x86, 0x2F, 0x83, 0x85, 0xDD, 0xFA, 0x9D, 0x4B, 0x7F, + 0xA2, 0xC0, 0x87, 0xE8, 0x79, 0x68, 0x33, 0x03, 0xED, 0x5B, 0xDD, 0x3A, + 0x06, 0x2B, 0x3C, 0xF5, 0xB3, 0xA2, 0x78, 0xA6, 0x6D, 0x2A, 0x13, 0xF8, + 0x3F, 0x44, 0xF8, 0x2D, 0xDF, 0x31, 0x0E, 0xE0, 0x74, 0xAB, 0x6A, 0x36, + 0x45, 0x97, 0xE8, 0x99, 0xA0, 0x25, 0x5D, 0xC1, 0x64, 0xF3, 0x1C, 0xC5, + 0x08, 0x46, 0x85, 0x1D, 0xF9, 0xAB, 0x48, 0x19, 0x5D, 0xED, 0x7E, 0xA1, + 0xB1, 0xD5, 0x10, 0xBD, 0x7E, 0xE7, 0x4D, 0x73, 0xFA, 0xF3, 0x6B, 0xC3, + 0x1E, 0xCF, 0xA2, 0x68, 0x35, 0x90, 0x46, 0xF4, 0xEB, 0x87, 0x9F, 0x92, + 0x40, 0x09, 0x43, 0x8B, 0x48, 0x1C, 0x6C, 0xD7, 0x88, 0x9A, 0x00, 0x2E, + 0xD5, 0xEE, 0x38, 0x2B, 0xC9, 0x19, 0x0D, 0xA6, 0xFC, 0x02, 0x6E, 0x47, + 0x95, 0x58, 0xE4, 0x47, 0x56, 0x77, 0xE9, 0xAA, 0x9E, 0x30, 0x50, 0xE2, + 0x76, 0x56, 0x94, 0xDF, 0xC8, 0x1F, 0x56, 0xE8, 0x80, 0xB9, 0x6E, 0x71, + 0x60, 0xC9, 0x80, 0xDD, 0x98, 0xED, 0xD3, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, +}; + BIGNUM * get_rfc3526_prime_8192(BIGNUM *bn) { - static const unsigned char RFC3526_PRIME_8192[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, - 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, - 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, - 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, - 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, - 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, - 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, - 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, - 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, - 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, - 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, - 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, - 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, - 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, - 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, - 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, - 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, - 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, - 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, - 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, - 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, - 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, - 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, - 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, - 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, - 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, - 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, - 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, - 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, - 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, - 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, - 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, - 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, - 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, - 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, - 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, - 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x02, 0x84, 0x92, - 0x36, 0xC3, 0xFA, 0xB4, 0xD2, 0x7C, 0x70, 0x26, 0xC1, 0xD4, 0xDC, 0xB2, - 0x60, 0x26, 0x46, 0xDE, 0xC9, 0x75, 0x1E, 0x76, 0x3D, 0xBA, 0x37, 0xBD, - 0xF8, 0xFF, 0x94, 0x06, 0xAD, 0x9E, 0x53, 0x0E, 0xE5, 0xDB, 0x38, 0x2F, - 0x41, 0x30, 0x01, 0xAE, 0xB0, 0x6A, 0x53, 0xED, 0x90, 0x27, 0xD8, 0x31, - 0x17, 0x97, 0x27, 0xB0, 0x86, 0x5A, 0x89, 0x18, 0xDA, 0x3E, 0xDB, 0xEB, - 0xCF, 0x9B, 0x14, 0xED, 0x44, 0xCE, 0x6C, 0xBA, 0xCE, 0xD4, 0xBB, 0x1B, - 0xDB, 0x7F, 0x14, 0x47, 0xE6, 0xCC, 0x25, 0x4B, 0x33, 0x20, 0x51, 0x51, - 0x2B, 0xD7, 0xAF, 0x42, 0x6F, 0xB8, 0xF4, 0x01, 0x37, 0x8C, 0xD2, 0xBF, - 0x59, 0x83, 0xCA, 0x01, 0xC6, 0x4B, 0x92, 0xEC, 0xF0, 0x32, 0xEA, 0x15, - 0xD1, 0x72, 0x1D, 0x03, 0xF4, 0x82, 0xD7, 0xCE, 0x6E, 0x74, 0xFE, 0xF6, - 0xD5, 0x5E, 0x70, 0x2F, 0x46, 0x98, 0x0C, 0x82, 0xB5, 0xA8, 0x40, 0x31, - 0x90, 0x0B, 0x1C, 0x9E, 0x59, 0xE7, 0xC9, 0x7F, 0xBE, 0xC7, 0xE8, 0xF3, - 0x23, 0xA9, 0x7A, 0x7E, 0x36, 0xCC, 0x88, 0xBE, 0x0F, 0x1D, 0x45, 0xB7, - 0xFF, 0x58, 0x5A, 0xC5, 0x4B, 0xD4, 0x07, 0xB2, 0x2B, 0x41, 0x54, 0xAA, - 0xCC, 0x8F, 0x6D, 0x7E, 0xBF, 0x48, 0xE1, 0xD8, 0x14, 0xCC, 0x5E, 0xD2, - 0x0F, 0x80, 0x37, 0xE0, 0xA7, 0x97, 0x15, 0xEE, 0xF2, 0x9B, 0xE3, 0x28, - 0x06, 0xA1, 0xD5, 0x8B, 0xB7, 0xC5, 0xDA, 0x76, 0xF5, 0x50, 0xAA, 0x3D, - 0x8A, 0x1F, 0xBF, 0xF0, 0xEB, 0x19, 0xCC, 0xB1, 0xA3, 0x13, 0xD5, 0x5C, - 0xDA, 0x56, 0xC9, 0xEC, 0x2E, 0xF2, 0x96, 0x32, 0x38, 0x7F, 0xE8, 0xD7, - 0x6E, 0x3C, 0x04, 0x68, 0x04, 0x3E, 0x8F, 0x66, 0x3F, 0x48, 0x60, 0xEE, - 0x12, 0xBF, 0x2D, 0x5B, 0x0B, 0x74, 0x74, 0xD6, 0xE6, 0x94, 0xF9, 0x1E, - 0x6D, 0xBE, 0x11, 0x59, 0x74, 0xA3, 0x92, 0x6F, 0x12, 0xFE, 0xE5, 0xE4, - 0x38, 0x77, 0x7C, 0xB6, 0xA9, 0x32, 0xDF, 0x8C, 0xD8, 0xBE, 0xC4, 0xD0, - 0x73, 0xB9, 0x31, 0xBA, 0x3B, 0xC8, 0x32, 0xB6, 0x8D, 0x9D, 0xD3, 0x00, - 0x74, 0x1F, 0xA7, 0xBF, 0x8A, 0xFC, 0x47, 0xED, 0x25, 0x76, 0xF6, 0x93, - 0x6B, 0xA4, 0x24, 0x66, 0x3A, 0xAB, 0x63, 0x9C, 0x5A, 0xE4, 0xF5, 0x68, - 0x34, 0x23, 0xB4, 0x74, 0x2B, 0xF1, 0xC9, 0x78, 0x23, 0x8F, 0x16, 0xCB, - 0xE3, 0x9D, 0x65, 0x2D, 0xE3, 0xFD, 0xB8, 0xBE, 0xFC, 0x84, 0x8A, 0xD9, - 0x22, 0x22, 0x2E, 0x04, 0xA4, 0x03, 0x7C, 0x07, 0x13, 0xEB, 0x57, 0xA8, - 0x1A, 0x23, 0xF0, 0xC7, 0x34, 0x73, 0xFC, 0x64, 0x6C, 0xEA, 0x30, 0x6B, - 0x4B, 0xCB, 0xC8, 0x86, 0x2F, 0x83, 0x85, 0xDD, 0xFA, 0x9D, 0x4B, 0x7F, - 0xA2, 0xC0, 0x87, 0xE8, 0x79, 0x68, 0x33, 0x03, 0xED, 0x5B, 0xDD, 0x3A, - 0x06, 0x2B, 0x3C, 0xF5, 0xB3, 0xA2, 0x78, 0xA6, 0x6D, 0x2A, 0x13, 0xF8, - 0x3F, 0x44, 0xF8, 0x2D, 0xDF, 0x31, 0x0E, 0xE0, 0x74, 0xAB, 0x6A, 0x36, - 0x45, 0x97, 0xE8, 0x99, 0xA0, 0x25, 0x5D, 0xC1, 0x64, 0xF3, 0x1C, 0xC5, - 0x08, 0x46, 0x85, 0x1D, 0xF9, 0xAB, 0x48, 0x19, 0x5D, 0xED, 0x7E, 0xA1, - 0xB1, 0xD5, 0x10, 0xBD, 0x7E, 0xE7, 0x4D, 0x73, 0xFA, 0xF3, 0x6B, 0xC3, - 0x1E, 0xCF, 0xA2, 0x68, 0x35, 0x90, 0x46, 0xF4, 0xEB, 0x87, 0x9F, 0x92, - 0x40, 0x09, 0x43, 0x8B, 0x48, 0x1C, 0x6C, 0xD7, 0x88, 0x9A, 0x00, 0x2E, - 0xD5, 0xEE, 0x38, 0x2B, 0xC9, 0x19, 0x0D, 0xA6, 0xFC, 0x02, 0x6E, 0x47, - 0x95, 0x58, 0xE4, 0x47, 0x56, 0x77, 0xE9, 0xAA, 0x9E, 0x30, 0x50, 0xE2, - 0x76, 0x56, 0x94, 0xDF, 0xC8, 0x1F, 0x56, 0xE8, 0x80, 0xB9, 0x6E, 0x71, - 0x60, 0xC9, 0x80, 0xDD, 0x98, 0xED, 0xD3, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - }; return BN_bin2bn(RFC3526_PRIME_8192, sizeof(RFC3526_PRIME_8192), bn); } LCRYPTO_ALIAS(get_rfc3526_prime_8192); @@ -468,6 +484,6 @@ LCRYPTO_ALIAS(get_rfc3526_prime_8192); BIGNUM * BN_get_rfc3526_prime_8192(BIGNUM *bn) { - return get_rfc3526_prime_8192(bn); + return BN_bin2bn(RFC3526_PRIME_8192, sizeof(RFC3526_PRIME_8192), bn); } LCRYPTO_ALIAS(BN_get_rfc3526_prime_8192); diff --git a/lib/libcrypto/bn/bn_convert.c b/lib/libcrypto/bn/bn_convert.c index cb0a23e01..f09c9091e 100644 --- a/lib/libcrypto/bn/bn_convert.c +++ b/lib/libcrypto/bn/bn_convert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_convert.c,v 1.13 2023/07/08 12:21:58 beck Exp $ */ +/* $OpenBSD: bn_convert.c,v 1.15 2023/07/09 18:37:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -497,20 +497,27 @@ BN_dec2bn(BIGNUM **bnp, const char *s) } LCRYPTO_ALIAS(BN_dec2bn); -char * -BN_bn2hex(const BIGNUM *bn) +static int +bn_bn2hex_internal(const BIGNUM *bn, int include_sign, int nibbles_only, + char **out, size_t *out_len) { int started = 0; uint8_t *s = NULL; - size_t s_len; + size_t s_len = 0; BN_ULONG v, w; int i, j; CBB cbb; + CBS cbs; + uint8_t nul; + int ret = 0; + + *out = NULL; + *out_len = 0; if (!CBB_init(&cbb, 0)) goto err; - if (BN_is_negative(bn)) { + if (BN_is_negative(bn) && include_sign) { if (!CBB_add_u8(&cbb, '-')) goto err; } @@ -524,8 +531,10 @@ BN_bn2hex(const BIGNUM *bn) v = (w >> j) & 0xff; if (!started && v == 0) continue; - if (!CBB_add_u8(&cbb, hex_digits[v >> 4])) - goto err; + if (started || !nibbles_only || (v >> 4) != 0) { + if (!CBB_add_u8(&cbb, hex_digits[v >> 4])) + goto err; + } if (!CBB_add_u8(&cbb, hex_digits[v & 0xf])) goto err; started = 1; @@ -536,8 +545,45 @@ BN_bn2hex(const BIGNUM *bn) if (!CBB_finish(&cbb, &s, &s_len)) goto err; + /* The length of a C string does not include the terminating NUL. */ + CBS_init(&cbs, s, s_len); + if (!CBS_get_last_u8(&cbs, &nul)) + goto err; + + *out = (char *)CBS_data(&cbs); + *out_len = CBS_len(&cbs); + s = NULL; + s_len = 0; + + ret = 1; + err: CBB_cleanup(&cbb); + freezero(s, s_len); + + return ret; +} + +int +bn_bn2hex_nosign(const BIGNUM *bn, char **out, size_t *out_len) +{ + return bn_bn2hex_internal(bn, 0, 0, out, out_len); +} + +int +bn_bn2hex_nibbles(const BIGNUM *bn, char **out, size_t *out_len) +{ + return bn_bn2hex_internal(bn, 1, 1, out, out_len); +} + +char * +BN_bn2hex(const BIGNUM *bn) +{ + char *s; + size_t s_len; + + if (!bn_bn2hex_internal(bn, 1, 0, &s, &s_len)) + return NULL; return s; } @@ -725,48 +771,3 @@ BN_mpi2bn(const unsigned char *d, int n, BIGNUM *ain) return (a); } LCRYPTO_ALIAS(BN_mpi2bn); - -#ifndef OPENSSL_NO_BIO -int -BN_print_fp(FILE *fp, const BIGNUM *a) -{ - BIO *b; - int ret; - - if ((b = BIO_new(BIO_s_file())) == NULL) - return (0); - BIO_set_fp(b, fp, BIO_NOCLOSE); - ret = BN_print(b, a); - BIO_free(b); - return (ret); -} -LCRYPTO_ALIAS(BN_print_fp); - -int -BN_print(BIO *bp, const BIGNUM *a) -{ - int i, j, v, z = 0; - int ret = 0; - - if ((a->neg) && (BIO_write(bp, "-", 1) != 1)) - goto end; - if (BN_is_zero(a) && (BIO_write(bp, "0", 1) != 1)) - goto end; - for (i = a->top - 1; i >= 0; i--) { - for (j = BN_BITS2 - 4; j >= 0; j -= 4) { - /* strip leading zeros */ - v = ((int)(a->d[i] >> (long)j)) & 0x0f; - if (z || (v != 0)) { - if (BIO_write(bp, &hex_digits[v], 1) != 1) - goto end; - z = 1; - } - } - } - ret = 1; - -end: - return (ret); -} -LCRYPTO_ALIAS(BN_print); -#endif diff --git a/lib/libcrypto/bn/bn_local.h b/lib/libcrypto/bn/bn_local.h index 86aa97227..a8d40fbcc 100644 --- a/lib/libcrypto/bn/bn_local.h +++ b/lib/libcrypto/bn/bn_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_local.h,v 1.25 2023/07/06 14:37:39 tb Exp $ */ +/* $OpenBSD: bn_local.h,v 1.26 2023/07/09 18:27:22 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -327,5 +327,8 @@ int bn_printf(BIO *bio, const BIGNUM *bn, int indent, const char *fmt, ...) __attribute__((__format__ (printf, 4, 5))) __attribute__((__nonnull__ (4))); +int bn_bn2hex_nosign(const BIGNUM *bn, char **out, size_t *out_len); +int bn_bn2hex_nibbles(const BIGNUM *bn, char **out, size_t *out_len); + __END_HIDDEN_DECLS #endif /* !HEADER_BN_LOCAL_H */ diff --git a/lib/libcrypto/bn/bn_prime.c b/lib/libcrypto/bn/bn_prime.c index a09bac4ae..5a4aa50bf 100644 --- a/lib/libcrypto/bn/bn_prime.c +++ b/lib/libcrypto/bn/bn_prime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_prime.c,v 1.33 2023/07/08 12:21:58 beck Exp $ */ +/* $OpenBSD: bn_prime.c,v 1.34 2023/07/20 06:26:27 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -240,6 +240,8 @@ BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) } LCRYPTO_ALIAS(BN_is_prime_ex); +#define BN_PRIME_MAXIMUM_BITS (32 * 1024) + int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, int do_trial_division, BN_GENCB *cb) @@ -249,6 +251,15 @@ BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, if (checks < 0) return -1; + /* + * Prime numbers this large do not appear in everyday cryptography + * and checking such numbers for primality is very expensive. + */ + if (BN_num_bits(a) > BN_PRIME_MAXIMUM_BITS) { + BNerror(BN_R_BIGNUM_TOO_LONG); + return -1; + } + if (checks == BN_prime_checks) checks = BN_prime_checks_for_size(BN_num_bits(a)); diff --git a/lib/libcrypto/bn/bn_print.c b/lib/libcrypto/bn/bn_print.c index 84b820396..afcb82396 100644 --- a/lib/libcrypto/bn/bn_print.c +++ b/lib/libcrypto/bn/bn_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_print.c,v 1.42 2023/07/07 07:04:24 tb Exp $ */ +/* $OpenBSD: bn_print.c,v 1.45 2023/07/10 02:29:28 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler @@ -19,13 +19,14 @@ #include #include #include +#include #include #include -#include #include #include +#include "bn_local.h" #include "bytestring.h" static int @@ -80,17 +81,14 @@ bn_print_bignum(BIO *bio, const BIGNUM *bn, int indent) if (indent < 0) indent = 0; - if ((hex = BN_bn2hex(bn)) == NULL) + if (!bn_bn2hex_nosign(bn, &hex, &hex_len)) goto err; - hex_len = strlen(hex); CBS_init(&cbs, hex, hex_len); if (BN_is_negative(bn)) { if (BIO_printf(bio, " (Negative)") <= 0) goto err; - if (!CBS_skip(&cbs, 1)) - goto err; } while (CBS_len(&cbs) > 0) { @@ -151,3 +149,45 @@ bn_printf(BIO *bio, const BIGNUM *bn, int indent, const char *fmt, ...) return bn_print_bignum(bio, bn, indent); } + +int +BN_print(BIO *bio, const BIGNUM *bn) +{ + char *hex = NULL; + size_t hex_len = 0; + int ret = 0; + + if (!bn_bn2hex_nibbles(bn, &hex, &hex_len)) + goto err; + if (BIO_printf(bio, "%s", hex) <= 0) + goto err; + + ret = 1; + + err: + freezero(hex, hex_len); + + return ret; +} +LCRYPTO_ALIAS(BN_print); + +int +BN_print_fp(FILE *fp, const BIGNUM *bn) +{ + char *hex = NULL; + size_t hex_len = 0; + int ret = 0; + + if (!bn_bn2hex_nibbles(bn, &hex, &hex_len)) + goto err; + if (fprintf(fp, "%s", hex) < 0) + goto err; + + ret = 1; + + err: + freezero(hex, hex_len); + + return ret; +} +LCRYPTO_ALIAS(BN_print_fp); diff --git a/lib/libcrypto/conf/conf_mod.c b/lib/libcrypto/conf/conf_mod.c index 9f252385e..aab108a26 100644 --- a/lib/libcrypto/conf/conf_mod.c +++ b/lib/libcrypto/conf/conf_mod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf_mod.c,v 1.27 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: conf_mod.c,v 1.28 2023/07/20 15:05:30 tb Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -63,21 +63,11 @@ #include #include -#include #include #include -#define DSO_mod_init_name "OPENSSL_init" -#define DSO_mod_finish_name "OPENSSL_finish" - -/* This structure contains a data about supported modules. - * entries in this table correspond to either dynamic or - * static modules. - */ - +/* This structure contains data about supported modules. */ struct conf_module_st { - /* DSO of this module or NULL if static */ - DSO *dso; /* Name of the module */ char *name; /* Init function */ @@ -110,13 +100,11 @@ static void module_free(CONF_MODULE *md); static void module_finish(CONF_IMODULE *imod); static int module_run(const CONF *cnf, char *name, char *value, unsigned long flags); -static CONF_MODULE *module_add(DSO *dso, const char *name, - conf_init_func *ifunc, conf_finish_func *ffunc); +static CONF_MODULE *module_add(const char *name, conf_init_func *ifunc, + conf_finish_func *ffunc); static CONF_MODULE *module_find(char *name); static int module_init(CONF_MODULE *pmod, char *name, char *value, const CONF *cnf); -static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value, - unsigned long flags); /* Main function: load modules from a CONF structure */ @@ -203,13 +191,7 @@ module_run(const CONF *cnf, char *name, char *value, unsigned long flags) CONF_MODULE *md; int ret; - md = module_find(name); - - /* Module not found: try to load DSO */ - if (!md && !(flags & CONF_MFLAGS_NO_DSO)) - md = module_load_dso(cnf, name, value, flags); - - if (!md) { + if ((md = module_find(name)) == NULL) { if (!(flags & CONF_MFLAGS_SILENT)) { CONFerror(CONF_R_UNKNOWN_MODULE_NAME); ERR_asprintf_error_data("module=%s", name); @@ -231,54 +213,9 @@ module_run(const CONF *cnf, char *name, char *value, unsigned long flags) return ret; } -/* Load a module from a DSO */ -static CONF_MODULE * -module_load_dso(const CONF *cnf, char *name, char *value, unsigned long flags) -{ - DSO *dso = NULL; - conf_init_func *ifunc; - conf_finish_func *ffunc; - char *path = NULL; - int errcode = 0; - CONF_MODULE *md; - - /* Look for alternative path in module section */ - path = NCONF_get_string(cnf, value, "path"); - if (!path) { - ERR_clear_error(); - path = name; - } - dso = DSO_load(NULL, path, NULL, 0); - if (!dso) { - errcode = CONF_R_ERROR_LOADING_DSO; - goto err; - } - ifunc = (conf_init_func *)DSO_bind_func(dso, DSO_mod_init_name); - if (!ifunc) { - errcode = CONF_R_MISSING_INIT_FUNCTION; - goto err; - } - ffunc = (conf_finish_func *)DSO_bind_func(dso, DSO_mod_finish_name); - /* All OK, add module */ - md = module_add(dso, name, ifunc, ffunc); - - if (!md) - goto err; - - return md; - -err: - if (dso) - DSO_free(dso); - CONFerror(errcode); - ERR_asprintf_error_data("module=%s, path=%s", name, path); - return NULL; -} - /* add module to list */ static CONF_MODULE * -module_add(DSO *dso, const char *name, conf_init_func *ifunc, - conf_finish_func *ffunc) +module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) { CONF_MODULE *tmod = NULL; @@ -292,7 +229,6 @@ module_add(DSO *dso, const char *name, conf_init_func *ifunc, if (tmod == NULL) return NULL; - tmod->dso = dso; tmod->name = strdup(name); tmod->init = ifunc; tmod->finish = ffunc; @@ -412,8 +348,7 @@ CONF_modules_unload(int all) /* unload modules in reverse order */ for (i = sk_CONF_MODULE_num(supported_modules) - 1; i >= 0; i--) { md = sk_CONF_MODULE_value(supported_modules, i); - /* If static or in use and 'all' not set ignore it */ - if (((md->links > 0) || !md->dso) && !all) + if (!all) continue; /* Since we're working in reverse this is OK */ (void)sk_CONF_MODULE_delete(supported_modules, i); @@ -429,8 +364,6 @@ CONF_modules_unload(int all) static void module_free(CONF_MODULE *md) { - if (md->dso) - DSO_free(md->dso); free(md->name); free(md); } @@ -466,13 +399,9 @@ module_finish(CONF_IMODULE *imod) /* Add a static module to OpenSSL */ int -CONF_module_add(const char *name, conf_init_func *ifunc, - conf_finish_func *ffunc) +CONF_module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) { - if (module_add(NULL, name, ifunc, ffunc)) - return 1; - else - return 0; + return module_add(name, ifunc, ffunc) != NULL; } void diff --git a/lib/libcrypto/ecdh/ecdh.c b/lib/libcrypto/ecdh/ecdh.c index 0781c30e0..ecb849c13 100644 --- a/lib/libcrypto/ecdh/ecdh.c +++ b/lib/libcrypto/ecdh/ecdh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdh.c,v 1.4 2023/07/07 13:54:45 beck Exp $ */ +/* $OpenBSD: ecdh.c,v 1.5 2023/07/12 08:54:18 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -151,7 +151,7 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) { BN_CTX *ctx; - BIGNUM *cofactor, *x; + BIGNUM *x; const BIGNUM *priv_key; const EC_GROUP *group; EC_POINT *point = NULL; @@ -172,8 +172,6 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh if ((x = BN_CTX_get(ctx)) == NULL) goto err; - if ((cofactor = BN_CTX_get(ctx)) == NULL) - goto err; if ((group = EC_KEY_get0_group(ecdh)) == NULL) goto err; @@ -191,18 +189,6 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh goto err; } - if ((EC_KEY_get_flags(ecdh) & EC_FLAG_COFACTOR_ECDH) != 0) { - if (!EC_GROUP_get_cofactor(group, cofactor, NULL)) { - ECerror(ERR_R_EC_LIB); - goto err; - } - if (!BN_mul(cofactor, cofactor, priv_key, ctx)) { - ECerror(ERR_R_BN_LIB); - goto err; - } - priv_key = cofactor; - } - if (!EC_POINT_mul(group, point, NULL, pub_key, priv_key, ctx)) { ECerror(EC_R_POINT_ARITHMETIC_FAILURE); goto err; diff --git a/lib/libcrypto/ecdsa/ecdsa.c b/lib/libcrypto/ecdsa/ecdsa.c index 5a93b8463..e47ec2128 100644 --- a/lib/libcrypto/ecdsa/ecdsa.c +++ b/lib/libcrypto/ecdsa/ecdsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdsa.c,v 1.11 2023/07/07 13:54:45 beck Exp $ */ +/* $OpenBSD: ecdsa.c,v 1.12 2023/07/10 19:10:51 tb Exp $ */ /* ==================================================================== * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. * @@ -166,17 +166,17 @@ ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) LCRYPTO_ALIAS(ECDSA_SIG_set0); int -ECDSA_size(const EC_KEY *r) +ECDSA_size(const EC_KEY *key) { const EC_GROUP *group; const BIGNUM *order = NULL; ECDSA_SIG sig; int ret = 0; - if (r == NULL) + if (key == NULL) goto err; - if ((group = EC_KEY_get0_group(r)) == NULL) + if ((group = EC_KEY_get0_group(key)) == NULL) goto err; if ((order = EC_GROUP_get0_order(group)) == NULL) diff --git a/lib/libcrypto/engine/eng_aesni.c b/lib/libcrypto/engine/eng_aesni.c deleted file mode 100644 index cce4203bc..000000000 --- a/lib/libcrypto/engine/eng_aesni.c +++ /dev/null @@ -1,562 +0,0 @@ -/* $OpenBSD: eng_aesni.c,v 1.12 2022/12/26 07:18:51 jmc Exp $ */ -/* - * Support for Intel AES-NI instruction set - * Author: Huang Ying - * - * Intel AES-NI is a new set of Single Instruction Multiple Data - * (SIMD) instructions that are going to be introduced in the next - * generation of Intel processor, as of 2009. These instructions - * enable fast and secure data encryption and decryption, using the - * Advanced Encryption Standard (AES), defined by FIPS Publication - * number 197. The architecture introduces six instructions that - * offer full hardware support for AES. Four of them support high - * performance data encryption and decryption, and the other two - * instructions support the AES key expansion procedure. - * - * The white paper can be downloaded from: - * http://softwarecommunity.intel.com/isn/downloads/intelavx/AES-Instructions-Set_WP.pdf - * - * This file is based on engines/e_padlock.c - */ - -/* ==================================================================== - * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include - -#include - -#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_AES_NI) && !defined(OPENSSL_NO_AES) - -#include -#include -#include -#include -#include - -/* AES-NI is available *ONLY* on some x86 CPUs. Not only that it - doesn't exist elsewhere, but it even can't be compiled on other - platforms! */ -#undef COMPILE_HW_AESNI -#if (defined(__x86_64) || defined(__x86_64__) || \ - defined(_M_AMD64) || defined(_M_X64) || \ - defined(OPENSSL_IA32_SSE2)) && !defined(OPENSSL_NO_ASM) && !defined(__i386__) -#define COMPILE_HW_AESNI -#include "x86_arch.h" -#endif -static ENGINE *ENGINE_aesni(void); - -void ENGINE_load_aesni(void) -{ -/* On non-x86 CPUs it just returns. */ -#ifdef COMPILE_HW_AESNI - ENGINE *toadd = ENGINE_aesni(); - if (toadd == NULL) - return; - ENGINE_add(toadd); - ENGINE_register_complete(toadd); - ENGINE_free(toadd); - ERR_clear_error(); -#endif -} - -#ifdef COMPILE_HW_AESNI -int aesni_set_encrypt_key(const unsigned char *userKey, int bits, - AES_KEY *key); -int aesni_set_decrypt_key(const unsigned char *userKey, int bits, - AES_KEY *key); - -void aesni_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); -void aesni_decrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); - -void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, int enc); -void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, unsigned char *ivec, int enc); - -/* Function for ENGINE detection and control */ -static int aesni_init(ENGINE *e); - -/* Cipher Stuff */ -static int aesni_ciphers(ENGINE *e, const EVP_CIPHER **cipher, - const int **nids, int nid); - -#define AESNI_MIN_ALIGN 16 -#define AESNI_ALIGN(x) \ - ((void *)(((unsigned long)(x)+AESNI_MIN_ALIGN-1)&~(AESNI_MIN_ALIGN-1))) - -/* Engine names */ -static const char aesni_id[] = "aesni", - aesni_name[] = "Intel AES-NI engine", - no_aesni_name[] = "Intel AES-NI engine (no-aesni)"; - - -/* The input and output encrypted as though 128bit cfb mode is being - * used. The extra state information to record how much of the - * 128bit block we have used is contained in *num; - */ -static void -aesni_cfb128_encrypt(const unsigned char *in, unsigned char *out, - unsigned int len, const void *key, unsigned char ivec[16], int *num, - int enc) -{ - unsigned int n; - size_t l = 0; - - n = *num; - - if (enc) { -#if !defined(OPENSSL_SMALL_FOOTPRINT) - if (16%sizeof(size_t) == 0) do { /* always true actually */ - while (n && len) { - *(out++) = ivec[n] ^= *(in++); - --len; - n = (n + 1) % 16; - } - while (len >= 16) { - aesni_encrypt(ivec, ivec, key); - for (n = 0; n < 16; n += sizeof(size_t)) { - *(size_t*)(out + n) = - *(size_t*)(ivec + n) ^= *(size_t*)(in + n); - } - len -= 16; - out += 16; - in += 16; - } - n = 0; - if (len) { - aesni_encrypt(ivec, ivec, key); - while (len--) { - out[n] = ivec[n] ^= in[n]; - ++n; - } - } - *num = n; - return; - } while (0); - /* the rest would be commonly eliminated by x86* compiler */ -#endif - while (l < len) { - if (n == 0) { - aesni_encrypt(ivec, ivec, key); - } - out[l] = ivec[n] ^= in[l]; - ++l; - n = (n + 1) % 16; - } - *num = n; - } else { -#if !defined(OPENSSL_SMALL_FOOTPRINT) - if (16%sizeof(size_t) == 0) do { /* always true actually */ - while (n && len) { - unsigned char c; - *(out++) = ivec[n] ^ (c = *(in++)); - ivec[n] = c; - --len; - n = (n + 1) % 16; - } - while (len >= 16) { - aesni_encrypt(ivec, ivec, key); - for (n = 0; n < 16; n += sizeof(size_t)) { - size_t t = *(size_t*)(in + n); - *(size_t*)(out + n) = *(size_t*)(ivec + n) ^ t; - *(size_t*)(ivec + n) = t; - } - len -= 16; - out += 16; - in += 16; - } - n = 0; - if (len) { - aesni_encrypt(ivec, ivec, key); - while (len--) { - unsigned char c; - out[n] = ivec[n] ^ (c = in[n]); - ivec[n] = c; - ++n; - } - } - *num = n; - return; - } while (0); - /* the rest would be commonly eliminated by x86* compiler */ -#endif - while (l < len) { - unsigned char c; - if (n == 0) { - aesni_encrypt(ivec, ivec, key); - } - out[l] = ivec[n] ^ (c = in[l]); - ivec[n] = c; - ++l; - n = (n + 1) % 16; - } - *num = n; - } -} - -/* The input and output encrypted as though 128bit ofb mode is being - * used. The extra state information to record how much of the - * 128bit block we have used is contained in *num; - */ -static void -aesni_ofb128_encrypt(const unsigned char *in, unsigned char *out, - unsigned int len, const void *key, unsigned char ivec[16], int *num) -{ - unsigned int n; - size_t l = 0; - - n = *num; - -#if !defined(OPENSSL_SMALL_FOOTPRINT) - if (16%sizeof(size_t) == 0) do { /* always true actually */ - while (n && len) { - *(out++) = *(in++) ^ ivec[n]; - --len; - n = (n + 1) % 16; - } - while (len >= 16) { - aesni_encrypt(ivec, ivec, key); - for (n = 0; n < 16; n += sizeof(size_t)) - *(size_t*)(out + n) = - *(size_t*)(in + n) ^ *(size_t*)(ivec + n); - len -= 16; - out += 16; - in += 16; - } - n = 0; - if (len) { - aesni_encrypt(ivec, ivec, key); - while (len--) { - out[n] = in[n] ^ ivec[n]; - ++n; - } - } - *num = n; - return; - } while (0); - /* the rest would be commonly eliminated by x86* compiler */ -#endif - while (l < len) { - if (n == 0) { - aesni_encrypt(ivec, ivec, key); - } - out[l] = in[l] ^ ivec[n]; - ++l; - n = (n + 1) % 16; - } - - *num = n; -} -/* ===== Engine "management" functions ===== */ - -/* Prepare the ENGINE structure for registration */ -static int -aesni_bind_helper(ENGINE *e) -{ - int engage; - - engage = (OPENSSL_cpu_caps() & CPUCAP_MASK_AESNI) != 0; - - /* Register everything or return with an error */ - if (!ENGINE_set_id(e, aesni_id) || - !ENGINE_set_name(e, engage ? aesni_name : no_aesni_name) || - !ENGINE_set_init_function(e, aesni_init) || - (engage && !ENGINE_set_ciphers (e, aesni_ciphers))) - return 0; - - /* Everything looks good */ - return 1; -} - -/* Constructor */ -static ENGINE * -ENGINE_aesni(void) -{ - ENGINE *eng = ENGINE_new(); - - if (!eng) { - return NULL; - } - - if (!aesni_bind_helper(eng)) { - ENGINE_free(eng); - return NULL; - } - - return eng; -} - -/* Check availability of the engine */ -static int -aesni_init(ENGINE *e) -{ - return 1; -} - -#if defined(NID_aes_128_cfb128) && ! defined (NID_aes_128_cfb) -#define NID_aes_128_cfb NID_aes_128_cfb128 -#endif - -#if defined(NID_aes_128_ofb128) && ! defined (NID_aes_128_ofb) -#define NID_aes_128_ofb NID_aes_128_ofb128 -#endif - -#if defined(NID_aes_192_cfb128) && ! defined (NID_aes_192_cfb) -#define NID_aes_192_cfb NID_aes_192_cfb128 -#endif - -#if defined(NID_aes_192_ofb128) && ! defined (NID_aes_192_ofb) -#define NID_aes_192_ofb NID_aes_192_ofb128 -#endif - -#if defined(NID_aes_256_cfb128) && ! defined (NID_aes_256_cfb) -#define NID_aes_256_cfb NID_aes_256_cfb128 -#endif - -#if defined(NID_aes_256_ofb128) && ! defined (NID_aes_256_ofb) -#define NID_aes_256_ofb NID_aes_256_ofb128 -#endif - -/* List of supported ciphers. */ -static int aesni_cipher_nids[] = { - NID_aes_128_ecb, - NID_aes_128_cbc, - NID_aes_128_cfb, - NID_aes_128_ofb, - - NID_aes_192_ecb, - NID_aes_192_cbc, - NID_aes_192_cfb, - NID_aes_192_ofb, - - NID_aes_256_ecb, - NID_aes_256_cbc, - NID_aes_256_cfb, - NID_aes_256_ofb, -}; -static int aesni_cipher_nids_num = - (sizeof(aesni_cipher_nids) / sizeof(aesni_cipher_nids[0])); - -typedef struct { - AES_KEY ks; - unsigned int _pad1[3]; -} AESNI_KEY; - -static int -aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *user_key, - const unsigned char *iv, int enc) -{ - int ret; - AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); - - if ((ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_CFB_MODE || - (ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_OFB_MODE || - enc) - ret = aesni_set_encrypt_key(user_key, ctx->key_len * 8, key); - else - ret = aesni_set_decrypt_key(user_key, ctx->key_len * 8, key); - - if (ret < 0) { - EVPerror(EVP_R_AES_KEY_SETUP_FAILED); - return 0; - } - - return 1; -} - -static int -aesni_cipher_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl) -{ - AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); - - aesni_ecb_encrypt(in, out, inl, key, ctx->encrypt); - return 1; -} - -static int -aesni_cipher_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl) -{ - AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); - - aesni_cbc_encrypt(in, out, inl, key, ctx->iv, ctx->encrypt); - return 1; -} - -static int -aesni_cipher_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl) -{ - AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); - - aesni_cfb128_encrypt(in, out, inl, key, ctx->iv, &ctx->num, - ctx->encrypt); - return 1; -} - -static int -aesni_cipher_ofb(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl) -{ - AES_KEY *key = AESNI_ALIGN(ctx->cipher_data); - - aesni_ofb128_encrypt(in, out, inl, key, ctx->iv, &ctx->num); - return 1; -} - -#define AES_BLOCK_SIZE 16 - -#define EVP_CIPHER_block_size_ECB AES_BLOCK_SIZE -#define EVP_CIPHER_block_size_CBC AES_BLOCK_SIZE -#define EVP_CIPHER_block_size_OFB 1 -#define EVP_CIPHER_block_size_CFB 1 - -/* Declaring so many ciphers by hand would be a pain. - Instead introduce a bit of preprocessor magic :-) */ -#define DECLARE_AES_EVP(ksize,lmode,umode) \ -static const EVP_CIPHER aesni_##ksize##_##lmode = { \ - NID_aes_##ksize##_##lmode, \ - EVP_CIPHER_block_size_##umode, \ - ksize / 8, \ - AES_BLOCK_SIZE, \ - 0 | EVP_CIPH_##umode##_MODE, \ - aesni_init_key, \ - aesni_cipher_##lmode, \ - NULL, \ - sizeof(AESNI_KEY), \ - EVP_CIPHER_set_asn1_iv, \ - EVP_CIPHER_get_asn1_iv, \ - NULL, \ - NULL \ -} - -DECLARE_AES_EVP(128, ecb, ECB); -DECLARE_AES_EVP(128, cbc, CBC); -DECLARE_AES_EVP(128, cfb, CFB); -DECLARE_AES_EVP(128, ofb, OFB); - -DECLARE_AES_EVP(192, ecb, ECB); -DECLARE_AES_EVP(192, cbc, CBC); -DECLARE_AES_EVP(192, cfb, CFB); -DECLARE_AES_EVP(192, ofb, OFB); - -DECLARE_AES_EVP(256, ecb, ECB); -DECLARE_AES_EVP(256, cbc, CBC); -DECLARE_AES_EVP(256, cfb, CFB); -DECLARE_AES_EVP(256, ofb, OFB); - -static int -aesni_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid) -{ - /* No specific cipher => return a list of supported nids ... */ - if (!cipher) { - *nids = aesni_cipher_nids; - return aesni_cipher_nids_num; - } - - /* ... or the requested "cipher" otherwise */ - switch (nid) { - case NID_aes_128_ecb: - *cipher = &aesni_128_ecb; - break; - case NID_aes_128_cbc: - *cipher = &aesni_128_cbc; - break; - case NID_aes_128_cfb: - *cipher = &aesni_128_cfb; - break; - case NID_aes_128_ofb: - *cipher = &aesni_128_ofb; - break; - - case NID_aes_192_ecb: - *cipher = &aesni_192_ecb; - break; - case NID_aes_192_cbc: - *cipher = &aesni_192_cbc; - break; - case NID_aes_192_cfb: - *cipher = &aesni_192_cfb; - break; - case NID_aes_192_ofb: - *cipher = &aesni_192_ofb; - break; - - case NID_aes_256_ecb: - *cipher = &aesni_256_ecb; - break; - case NID_aes_256_cbc: - *cipher = &aesni_256_cbc; - break; - case NID_aes_256_cfb: - *cipher = &aesni_256_cfb; - break; - case NID_aes_256_ofb: - *cipher = &aesni_256_ofb; - break; - - default: - /* Sorry, we don't support this NID */ - *cipher = NULL; - return 0; - } - return 1; -} - -#endif /* COMPILE_HW_AESNI */ -#endif /* !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_AESNI) && !defined(OPENSSL_NO_AES) */ diff --git a/lib/libcrypto/engine/eng_openssl.c b/lib/libcrypto/engine/eng_openssl.c index c632279fa..4e0f144e8 100644 --- a/lib/libcrypto/engine/eng_openssl.c +++ b/lib/libcrypto/engine/eng_openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_openssl.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ +/* $OpenBSD: eng_openssl.c,v 1.17 2023/07/20 15:08:12 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -67,7 +67,6 @@ #include #include -#include #include #include #include diff --git a/lib/libcrypto/engine/eng_padlock.c b/lib/libcrypto/engine/eng_padlock.c deleted file mode 100644 index 50b5fb780..000000000 --- a/lib/libcrypto/engine/eng_padlock.c +++ /dev/null @@ -1,1129 +0,0 @@ -/* $OpenBSD: eng_padlock.c,v 1.17 2022/12/26 07:18:51 jmc Exp $ */ -/* - * Support for VIA PadLock Advanced Cryptography Engine (ACE) - * Written by Michal Ludvig - * http://www.logix.cz/michal - * - * Big thanks to Andy Polyakov for a help with optimization, - * assembler fixes, port to MS Windows and a lot of other - * valuable work on this engine! - */ - -/* ==================================================================== - * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include -#include - -#include - -#include -#include -#include -#include -#ifndef OPENSSL_NO_AES -#include -#endif -#include - -#ifndef OPENSSL_NO_HW -#ifndef OPENSSL_NO_HW_PADLOCK - -/* Attempt to have a single source for both 0.9.7 and 0.9.8 :-) */ -#if (OPENSSL_VERSION_NUMBER >= 0x00908000L) -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -# define DYNAMIC_ENGINE -# endif -#elif (OPENSSL_VERSION_NUMBER >= 0x00907000L) -# ifdef ENGINE_DYNAMIC_SUPPORT -# define DYNAMIC_ENGINE -# endif -#else -# error "Only OpenSSL >= 0.9.7 is supported" -#endif - -/* VIA PadLock AES is available *ONLY* on some x86 CPUs. - Not only that it doesn't exist elsewhere, but it - even can't be compiled on other platforms! - - In addition, because of the heavy use of inline assembler, - compiler choice is limited to GCC and Microsoft C. */ -#undef COMPILE_HW_PADLOCK -#if !defined(OPENSSL_NO_INLINE_ASM) -# if (defined(__GNUC__) && (defined(__i386__) || defined(__i386))) -# define COMPILE_HW_PADLOCK -# endif -#endif - -#ifdef OPENSSL_NO_DYNAMIC_ENGINE -#ifdef COMPILE_HW_PADLOCK -static ENGINE *ENGINE_padlock(void); -#endif - -void -ENGINE_load_padlock(void) -{ -/* On non-x86 CPUs it just returns. */ -#ifdef COMPILE_HW_PADLOCK - ENGINE *toadd = ENGINE_padlock(); - - if (toadd == NULL) - return; - ENGINE_add(toadd); - ENGINE_free(toadd); - ERR_clear_error(); -#endif -} - -#endif - -#ifdef COMPILE_HW_PADLOCK -/* We do these includes here to avoid header problems on platforms that - do not have the VIA padlock anyway... */ -#include -#if defined(__GNUC__) -# ifndef alloca -# define alloca(s) __builtin_alloca(s) -# endif -#endif - -/* Function for ENGINE detection and control */ -static int padlock_available(void); -static int padlock_init(ENGINE *e); - -/* RNG Stuff */ -static RAND_METHOD padlock_rand; - -/* Cipher Stuff */ -#ifndef OPENSSL_NO_AES -static int padlock_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); -#endif - -/* Engine names */ -static const char *padlock_id = "padlock"; -static char padlock_name[100]; - -/* Available features */ -static int padlock_use_ace = 0; /* Advanced Cryptography Engine */ -static int padlock_use_rng = 0; /* Random Number Generator */ -#ifndef OPENSSL_NO_AES -static int padlock_aes_align_required = 1; -#endif - -/* ===== Engine "management" functions ===== */ - -/* Prepare the ENGINE structure for registration */ -static int -padlock_bind_helper(ENGINE *e) -{ - /* Check available features */ - padlock_available(); - - /* - * RNG is currently disabled for reasons discussed in commentary just - * before padlock_rand_bytes function. - */ - padlock_use_rng = 0; - - /* Generate a nice engine name with available features */ - (void) snprintf(padlock_name, sizeof(padlock_name), - "VIA PadLock (%s, %s)", - padlock_use_rng ? "RNG" : "no-RNG", - padlock_use_ace ? "ACE" : "no-ACE"); - - /* Register everything or return with an error */ - if (!ENGINE_set_id(e, padlock_id) || - !ENGINE_set_name(e, padlock_name) || - !ENGINE_set_init_function(e, padlock_init) || -#ifndef OPENSSL_NO_AES - (padlock_use_ace && !ENGINE_set_ciphers (e, padlock_ciphers)) || -#endif - (padlock_use_rng && !ENGINE_set_RAND (e, &padlock_rand))) { - return 0; - } - - /* Everything looks good */ - return 1; -} - -#ifdef OPENSSL_NO_DYNAMIC_ENGINE - -/* Constructor */ -static ENGINE * -ENGINE_padlock(void) -{ - ENGINE *eng = ENGINE_new(); - - if (eng == NULL) - return NULL; - - if (!padlock_bind_helper(eng)) { - ENGINE_free(eng); - return NULL; - } - - return eng; -} - -#endif - -/* Check availability of the engine */ -static int -padlock_init(ENGINE *e) -{ - return (padlock_use_rng || padlock_use_ace); -} - -/* This stuff is needed if this ENGINE is being compiled into a self-contained - * shared-library. - */ -#ifdef DYNAMIC_ENGINE -static int -padlock_bind_fn(ENGINE *e, const char *id) -{ - if (id && (strcmp(id, padlock_id) != 0)) { - return 0; - } - - if (!padlock_bind_helper(e)) { - return 0; - } - - return 1; -} - -IMPLEMENT_DYNAMIC_CHECK_FN() -IMPLEMENT_DYNAMIC_BIND_FN (padlock_bind_fn) -#endif /* DYNAMIC_ENGINE */ - -/* ===== Here comes the "real" engine ===== */ - -#ifndef OPENSSL_NO_AES -/* Some AES-related constants */ -#define AES_BLOCK_SIZE 16 -#define AES_KEY_SIZE_128 16 -#define AES_KEY_SIZE_192 24 -#define AES_KEY_SIZE_256 32 - -/* Here we store the status information relevant to the - current context. */ -/* BIG FAT WARNING: - * Inline assembler in PADLOCK_XCRYPT_ASM() - * depends on the order of items in this structure. - * Don't blindly modify, reorder, etc! - */ -struct padlock_cipher_data { - unsigned char iv[AES_BLOCK_SIZE]; /* Initialization vector */ - union { - unsigned int pad[4]; - struct { - int rounds : 4; - int dgst : 1; /* n/a in C3 */ - int align : 1; /* n/a in C3 */ - int ciphr : 1; /* n/a in C3 */ - unsigned int keygen : 1; - int interm : 1; - unsigned int encdec : 1; - int ksize : 2; - } b; - } cword; /* Control word */ - AES_KEY ks; /* Encryption key */ -}; - -/* - * Essentially this variable belongs in thread local storage. - * Having this variable global on the other hand can only cause - * few bogus key reloads [if any at all on single-CPU system], - * so we accept the penalty... - */ -static volatile struct padlock_cipher_data *padlock_saved_context; -#endif - -/* - * ======================================================= - * Inline assembler section(s). - * ======================================================= - * Order of arguments is chosen to facilitate Windows port - * using __fastcall calling convention. If you wish to add - * more routines, keep in mind that first __fastcall - * argument is passed in %ecx and second - in %edx. - * ======================================================= - */ -#if defined(__GNUC__) && __GNUC__>=2 -/* - * As for excessive "push %ebx"/"pop %ebx" found all over. - * When generating position-independent code GCC won't let - * us use "b" in assembler templates nor even respect "ebx" - * in "clobber description." Therefore the trouble... - */ - -/* Helper function - check if a CPUID instruction - is available on this CPU */ -static int -padlock_insn_cpuid_available(void) -{ - int result = -1; - - /* We're checking if the bit #21 of EFLAGS - can be toggled. If yes = CPUID is available. */ - asm volatile ( - "pushf\n" - "popl %%eax\n" - "xorl $0x200000, %%eax\n" - "movl %%eax, %%ecx\n" - "andl $0x200000, %%ecx\n" - "pushl %%eax\n" - "popf\n" - "pushf\n" - "popl %%eax\n" - "andl $0x200000, %%eax\n" - "xorl %%eax, %%ecx\n" - "movl %%ecx, %0\n" - : "=r" (result) : : "eax", "ecx"); - - return (result == 0); -} - -/* Load supported features of the CPU to see if - the PadLock is available. */ -static int -padlock_available(void) -{ - char vendor_string[16]; - unsigned int eax, edx; - - /* First check if the CPUID instruction is available at all... */ - if (! padlock_insn_cpuid_available()) - return 0; - - /* Are we running on the Centaur (VIA) CPU? */ - eax = 0x00000000; - vendor_string[12] = 0; - asm volatile ( - "pushl %%ebx\n" - "cpuid\n" - "movl %%ebx,(%%edi)\n" - "movl %%edx,4(%%edi)\n" - "movl %%ecx,8(%%edi)\n" - "popl %%ebx" - : "+a"(eax) : "D"(vendor_string) : "ecx", "edx"); - if (strcmp(vendor_string, "CentaurHauls") != 0) - return 0; - - /* Check for Centaur Extended Feature Flags presence */ - eax = 0xC0000000; - asm volatile ("pushl %%ebx; cpuid; popl %%ebx" - : "+a"(eax) : : "ecx", "edx"); - if (eax < 0xC0000001) - return 0; - - /* Read the Centaur Extended Feature Flags */ - eax = 0xC0000001; - asm volatile ("pushl %%ebx; cpuid; popl %%ebx" - : "+a"(eax), "=d"(edx) : : "ecx"); - - /* Fill up some flags */ - padlock_use_ace = ((edx & (0x3 << 6)) == (0x3 << 6)); - padlock_use_rng = ((edx & (0x3 << 2)) == (0x3 << 2)); - - return padlock_use_ace + padlock_use_rng; -} - -#ifndef OPENSSL_NO_AES -/* Our own htonl()/ntohl() */ -static inline void -padlock_bswapl(AES_KEY *ks) -{ - size_t i = sizeof(ks->rd_key)/sizeof(ks->rd_key[0]); - unsigned int *key = ks->rd_key; - - while (i--) { - asm volatile ("bswapl %0" : "+r"(*key)); - key++; - } -} -#endif - -/* Force key reload from memory to the CPU microcode. - Loading EFLAGS from the stack clears EFLAGS[30] - which does the trick. */ -static inline void -padlock_reload_key(void) -{ - asm volatile ("pushfl; popfl"); -} - -#ifndef OPENSSL_NO_AES -/* - * This is heuristic key context tracing. At first one - * believes that one should use atomic swap instructions, - * but it's not actually necessary. Point is that if - * padlock_saved_context was changed by another thread - * after we've read it and before we compare it with cdata, - * our key *shall* be reloaded upon thread context switch - * and we are therefore set in either case... - */ -static inline void -padlock_verify_context(struct padlock_cipher_data *cdata) -{ - asm volatile ( - "pushfl\n" - " btl $30,(%%esp)\n" - " jnc 1f\n" - " cmpl %2,%1\n" - " je 1f\n" - " popfl\n" - " subl $4,%%esp\n" - "1: addl $4,%%esp\n" - " movl %2,%0" - :"+m"(padlock_saved_context) - : "r"(padlock_saved_context), "r"(cdata) : "cc"); -} - -/* Template for padlock_xcrypt_* modes */ -/* BIG FAT WARNING: - * The offsets used with 'leal' instructions - * describe items of the 'padlock_cipher_data' - * structure. - */ -#define PADLOCK_XCRYPT_ASM(name,rep_xcrypt) \ -static inline void *name(size_t cnt, \ - struct padlock_cipher_data *cdata, \ - void *out, const void *inp) \ -{ void *iv; \ - asm volatile ( "pushl %%ebx\n" \ - " leal 16(%0),%%edx\n" \ - " leal 32(%0),%%ebx\n" \ - rep_xcrypt "\n" \ - " popl %%ebx" \ - : "=a"(iv), "=c"(cnt), "=D"(out), "=S"(inp) \ - : "0"(cdata), "1"(cnt), "2"(out), "3"(inp) \ - : "edx", "cc", "memory"); \ - return iv; \ -} - -/* Generate all functions with appropriate opcodes */ -PADLOCK_XCRYPT_ASM(padlock_xcrypt_ecb, ".byte 0xf3,0x0f,0xa7,0xc8") /* rep xcryptecb */ -PADLOCK_XCRYPT_ASM(padlock_xcrypt_cbc, ".byte 0xf3,0x0f,0xa7,0xd0") /* rep xcryptcbc */ -PADLOCK_XCRYPT_ASM(padlock_xcrypt_cfb, ".byte 0xf3,0x0f,0xa7,0xe0") /* rep xcryptcfb */ -PADLOCK_XCRYPT_ASM(padlock_xcrypt_ofb, ".byte 0xf3,0x0f,0xa7,0xe8") /* rep xcryptofb */ -#endif - -/* The RNG call itself */ -static inline unsigned int -padlock_xstore(void *addr, unsigned int edx_in) -{ - unsigned int eax_out; - - asm volatile (".byte 0x0f,0xa7,0xc0" /* xstore */ - : "=a"(eax_out),"=m"(*(unsigned *)addr) - : "D"(addr), "d" (edx_in) - ); - - return eax_out; -} - -/* Why not inline 'rep movsd'? I failed to find information on what - * value in Direction Flag one can expect and consequently have to - * apply "better-safe-than-sorry" approach and assume "undefined." - * I could explicitly clear it and restore the original value upon - * return from padlock_aes_cipher, but it's presumably too much - * trouble for too little gain... - * - * In case you wonder 'rep xcrypt*' instructions above are *not* - * affected by the Direction Flag and pointers advance toward - * larger addresses unconditionally. - */ -static inline unsigned char * -padlock_memcpy(void *dst, const void *src, size_t n) -{ - long *d = dst; - const long *s = src; - - n /= sizeof(*d); - do { *d++ = *s++; - } while (--n); - - return dst; -} -#endif - -/* ===== AES encryption/decryption ===== */ -#ifndef OPENSSL_NO_AES - -#if defined(NID_aes_128_cfb128) && ! defined (NID_aes_128_cfb) -#define NID_aes_128_cfb NID_aes_128_cfb128 -#endif - -#if defined(NID_aes_128_ofb128) && ! defined (NID_aes_128_ofb) -#define NID_aes_128_ofb NID_aes_128_ofb128 -#endif - -#if defined(NID_aes_192_cfb128) && ! defined (NID_aes_192_cfb) -#define NID_aes_192_cfb NID_aes_192_cfb128 -#endif - -#if defined(NID_aes_192_ofb128) && ! defined (NID_aes_192_ofb) -#define NID_aes_192_ofb NID_aes_192_ofb128 -#endif - -#if defined(NID_aes_256_cfb128) && ! defined (NID_aes_256_cfb) -#define NID_aes_256_cfb NID_aes_256_cfb128 -#endif - -#if defined(NID_aes_256_ofb128) && ! defined (NID_aes_256_ofb) -#define NID_aes_256_ofb NID_aes_256_ofb128 -#endif - -/* List of supported ciphers. */ -static int padlock_cipher_nids[] = { - NID_aes_128_ecb, - NID_aes_128_cbc, - NID_aes_128_cfb, - NID_aes_128_ofb, - - NID_aes_192_ecb, - NID_aes_192_cbc, - NID_aes_192_cfb, - NID_aes_192_ofb, - - NID_aes_256_ecb, - NID_aes_256_cbc, - NID_aes_256_cfb, - NID_aes_256_ofb, -}; -static int padlock_cipher_nids_num = (sizeof(padlock_cipher_nids)/ -sizeof(padlock_cipher_nids[0])); - -/* Function prototypes ... */ -static int padlock_aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, - const unsigned char *iv, int enc); -static int padlock_aes_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t nbytes); - -#define NEAREST_ALIGNED(ptr) ( (unsigned char *)(ptr) + \ - ( (0x10 - ((size_t)(ptr) & 0x0F)) & 0x0F ) ) -#define ALIGNED_CIPHER_DATA(ctx) ((struct padlock_cipher_data *)\ - NEAREST_ALIGNED(ctx->cipher_data)) - -#define EVP_CIPHER_block_size_ECB AES_BLOCK_SIZE -#define EVP_CIPHER_block_size_CBC AES_BLOCK_SIZE -#define EVP_CIPHER_block_size_OFB 1 -#define EVP_CIPHER_block_size_CFB 1 - -/* Declaring so many ciphers by hand would be a pain. - Instead introduce a bit of preprocessor magic :-) */ -#define DECLARE_AES_EVP(ksize,lmode,umode) \ -static const EVP_CIPHER padlock_aes_##ksize##_##lmode = { \ - NID_aes_##ksize##_##lmode, \ - EVP_CIPHER_block_size_##umode, \ - AES_KEY_SIZE_##ksize, \ - AES_BLOCK_SIZE, \ - 0 | EVP_CIPH_##umode##_MODE, \ - padlock_aes_init_key, \ - padlock_aes_cipher, \ - NULL, \ - sizeof(struct padlock_cipher_data) + 16, \ - EVP_CIPHER_set_asn1_iv, \ - EVP_CIPHER_get_asn1_iv, \ - NULL, \ - NULL \ -} - -DECLARE_AES_EVP(128, ecb, ECB); -DECLARE_AES_EVP(128, cbc, CBC); -DECLARE_AES_EVP(128, cfb, CFB); -DECLARE_AES_EVP(128, ofb, OFB); - -DECLARE_AES_EVP(192, ecb, ECB); -DECLARE_AES_EVP(192, cbc, CBC); -DECLARE_AES_EVP(192, cfb, CFB); -DECLARE_AES_EVP(192, ofb, OFB); - -DECLARE_AES_EVP(256, ecb, ECB); -DECLARE_AES_EVP(256, cbc, CBC); -DECLARE_AES_EVP(256, cfb, CFB); -DECLARE_AES_EVP(256, ofb, OFB); - -static int -padlock_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid) -{ - /* No specific cipher => return a list of supported nids ... */ - if (!cipher) { - *nids = padlock_cipher_nids; - return padlock_cipher_nids_num; - } - - /* ... or the requested "cipher" otherwise */ - switch (nid) { - case NID_aes_128_ecb: - *cipher = &padlock_aes_128_ecb; - break; - case NID_aes_128_cbc: - *cipher = &padlock_aes_128_cbc; - break; - case NID_aes_128_cfb: - *cipher = &padlock_aes_128_cfb; - break; - case NID_aes_128_ofb: - *cipher = &padlock_aes_128_ofb; - break; - case NID_aes_192_ecb: - *cipher = &padlock_aes_192_ecb; - break; - case NID_aes_192_cbc: - *cipher = &padlock_aes_192_cbc; - break; - case NID_aes_192_cfb: - *cipher = &padlock_aes_192_cfb; - break; - case NID_aes_192_ofb: - *cipher = &padlock_aes_192_ofb; - break; - case NID_aes_256_ecb: - *cipher = &padlock_aes_256_ecb; - break; - case NID_aes_256_cbc: - *cipher = &padlock_aes_256_cbc; - break; - case NID_aes_256_cfb: - *cipher = &padlock_aes_256_cfb; - break; - case NID_aes_256_ofb: - *cipher = &padlock_aes_256_ofb; - break; - default: - /* Sorry, we don't support this NID */ - *cipher = NULL; - return 0; - } - - return 1; -} - -/* Prepare the encryption key for PadLock usage */ -static int -padlock_aes_init_key (EVP_CIPHER_CTX *ctx, const unsigned char *key, - const unsigned char *iv, int enc) -{ - struct padlock_cipher_data *cdata; - int key_len = EVP_CIPHER_CTX_key_length(ctx) * 8; - - if (key == NULL) - return 0; /* ERROR */ - - cdata = ALIGNED_CIPHER_DATA(ctx); - memset(cdata, 0, sizeof(struct padlock_cipher_data)); - - /* Prepare Control word. */ - if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE) - cdata->cword.b.encdec = 0; - else - cdata->cword.b.encdec = (ctx->encrypt == 0); - cdata->cword.b.rounds = 10 + (key_len - 128) / 32; - cdata->cword.b.ksize = (key_len - 128) / 64; - - switch (key_len) { - case 128: - /* PadLock can generate an extended key for - AES128 in hardware */ - memcpy(cdata->ks.rd_key, key, AES_KEY_SIZE_128); - cdata->cword.b.keygen = 0; - break; - - case 192: - case 256: - /* Generate an extended AES key in software. - Needed for AES192/AES256 */ - /* Well, the above applies to Stepping 8 CPUs - and is listed as hardware errata. They most - likely will fix it at some point and then - a check for stepping would be due here. */ - if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_CFB_MODE || - EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE || - enc) - AES_set_encrypt_key(key, key_len, &cdata->ks); - else - AES_set_decrypt_key(key, key_len, &cdata->ks); -#ifndef AES_ASM - /* OpenSSL C functions use byte-swapped extended key. */ - padlock_bswapl(&cdata->ks); -#endif - cdata->cword.b.keygen = 1; - break; - - default: - /* ERROR */ - return 0; - } - - /* - * This is done to cover for cases when user reuses the - * context for new key. The catch is that if we don't do - * this, padlock_eas_cipher might proceed with old key... - */ - padlock_reload_key (); - - return 1; -} - -/* - * Simplified version of padlock_aes_cipher() used when - * 1) both input and output buffers are at aligned addresses. - * or when - * 2) running on a newer CPU that doesn't require aligned buffers. - */ -static int -padlock_aes_cipher_omnivorous(EVP_CIPHER_CTX *ctx, unsigned char *out_arg, - const unsigned char *in_arg, size_t nbytes) -{ - struct padlock_cipher_data *cdata; - void *iv; - - cdata = ALIGNED_CIPHER_DATA(ctx); - padlock_verify_context(cdata); - - switch (EVP_CIPHER_CTX_mode(ctx)) { - case EVP_CIPH_ECB_MODE: - padlock_xcrypt_ecb(nbytes / AES_BLOCK_SIZE, cdata, - out_arg, in_arg); - break; - - case EVP_CIPH_CBC_MODE: - memcpy(cdata->iv, ctx->iv, AES_BLOCK_SIZE); - iv = padlock_xcrypt_cbc(nbytes / AES_BLOCK_SIZE, cdata, - out_arg, in_arg); - memcpy(ctx->iv, iv, AES_BLOCK_SIZE); - break; - - case EVP_CIPH_CFB_MODE: - memcpy(cdata->iv, ctx->iv, AES_BLOCK_SIZE); - iv = padlock_xcrypt_cfb(nbytes / AES_BLOCK_SIZE, cdata, - out_arg, in_arg); - memcpy(ctx->iv, iv, AES_BLOCK_SIZE); - break; - - case EVP_CIPH_OFB_MODE: - memcpy(cdata->iv, ctx->iv, AES_BLOCK_SIZE); - padlock_xcrypt_ofb(nbytes / AES_BLOCK_SIZE, cdata, - out_arg, in_arg); - memcpy(ctx->iv, cdata->iv, AES_BLOCK_SIZE); - break; - - default: - return 0; - } - - memset(cdata->iv, 0, AES_BLOCK_SIZE); - - return 1; -} - -#ifndef PADLOCK_CHUNK -# define PADLOCK_CHUNK 512 /* Must be a power of 2 larger than 16 */ -#endif -#if PADLOCK_CHUNK<16 || PADLOCK_CHUNK&(PADLOCK_CHUNK-1) -# error "insane PADLOCK_CHUNK..." -#endif - -/* Re-align the arguments to 16-Bytes boundaries and run the - encryption function itself. This function is not AES-specific. */ -static int -padlock_aes_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg, - const unsigned char *in_arg, size_t nbytes) -{ - struct padlock_cipher_data *cdata; - const void *inp; - unsigned char *out; - void *iv; - int inp_misaligned, out_misaligned, realign_in_loop; - size_t chunk, allocated = 0; - - /* ctx->num is maintained in byte-oriented modes, - such as CFB and OFB... */ - if ((chunk = ctx->num)) { - /* borrow chunk variable */ - unsigned char *ivp = ctx->iv; - - switch (EVP_CIPHER_CTX_mode(ctx)) { - case EVP_CIPH_CFB_MODE: - if (chunk >= AES_BLOCK_SIZE) - return 0; /* bogus value */ - - if (ctx->encrypt) - while (chunk < AES_BLOCK_SIZE && nbytes != 0) { - ivp[chunk] = *(out_arg++) = *(in_arg++) ^ ivp[chunk]; - chunk++, nbytes--; - } - else - while (chunk < AES_BLOCK_SIZE && nbytes != 0) { - unsigned char c = *(in_arg++); - *(out_arg++) = c ^ ivp[chunk]; - ivp[chunk++] = c, nbytes--; - } - - ctx->num = chunk % AES_BLOCK_SIZE; - break; - case EVP_CIPH_OFB_MODE: - if (chunk >= AES_BLOCK_SIZE) - return 0; /* bogus value */ - - while (chunk < AES_BLOCK_SIZE && nbytes != 0) { - *(out_arg++) = *(in_arg++) ^ ivp[chunk]; - chunk++, nbytes--; - } - - ctx->num = chunk % AES_BLOCK_SIZE; - break; - } - } - - if (nbytes == 0) - return 1; -#if 0 - if (nbytes % AES_BLOCK_SIZE) - return 0; /* are we expected to do tail processing? */ -#else - /* nbytes is always multiple of AES_BLOCK_SIZE in ECB and CBC - modes and arbitrary value in byte-oriented modes, such as - CFB and OFB... */ -#endif - - /* VIA promises CPUs that won't require alignment in the future. - For now padlock_aes_align_required is initialized to 1 and - the condition is never met... */ - /* C7 core is capable to manage unaligned input in non-ECB[!] - mode, but performance penalties appear to be approximately - same as for software alignment below or ~3x. They promise to - improve it in the future, but for now we can just as well - pretend that it can only handle aligned input... */ - if (!padlock_aes_align_required && (nbytes % AES_BLOCK_SIZE) == 0) - return padlock_aes_cipher_omnivorous(ctx, out_arg, in_arg, - nbytes); - - inp_misaligned = (((size_t)in_arg) & 0x0F); - out_misaligned = (((size_t)out_arg) & 0x0F); - - /* Note that even if output is aligned and input not, - * I still prefer to loop instead of copy the whole - * input and then encrypt in one stroke. This is done - * in order to improve L1 cache utilization... */ - realign_in_loop = out_misaligned|inp_misaligned; - - if (!realign_in_loop && (nbytes % AES_BLOCK_SIZE) == 0) - return padlock_aes_cipher_omnivorous(ctx, out_arg, in_arg, - nbytes); - - /* this takes one "if" out of the loops */ - chunk = nbytes; - chunk %= PADLOCK_CHUNK; - if (chunk == 0) - chunk = PADLOCK_CHUNK; - - if (out_misaligned) { - /* optimize for small input */ - allocated = (chunk < nbytes ? PADLOCK_CHUNK : nbytes); - out = alloca(0x10 + allocated); - out = NEAREST_ALIGNED(out); - } else - out = out_arg; - - cdata = ALIGNED_CIPHER_DATA(ctx); - padlock_verify_context(cdata); - - switch (EVP_CIPHER_CTX_mode(ctx)) { - case EVP_CIPH_ECB_MODE: - do { - if (inp_misaligned) - inp = padlock_memcpy(out, in_arg, chunk); - else - inp = in_arg; - in_arg += chunk; - - padlock_xcrypt_ecb(chunk / AES_BLOCK_SIZE, cdata, - out, inp); - - if (out_misaligned) - out_arg = padlock_memcpy(out_arg, out, chunk) + - chunk; - else - out = out_arg += chunk; - - nbytes -= chunk; - chunk = PADLOCK_CHUNK; - } while (nbytes); - break; - - case EVP_CIPH_CBC_MODE: - memcpy(cdata->iv, ctx->iv, AES_BLOCK_SIZE); - goto cbc_shortcut; - do { - if (iv != cdata->iv) - memcpy(cdata->iv, iv, AES_BLOCK_SIZE); - chunk = PADLOCK_CHUNK; - cbc_shortcut: /* optimize for small input */ - if (inp_misaligned) - inp = padlock_memcpy(out, in_arg, chunk); - else - inp = in_arg; - in_arg += chunk; - - iv = padlock_xcrypt_cbc(chunk / AES_BLOCK_SIZE, cdata, - out, inp); - - if (out_misaligned) - out_arg = padlock_memcpy(out_arg, out, chunk) + - chunk; - else - out = out_arg += chunk; - } while (nbytes -= chunk); - memcpy(ctx->iv, iv, AES_BLOCK_SIZE); - break; - - case EVP_CIPH_CFB_MODE: - memcpy (iv = cdata->iv, ctx->iv, AES_BLOCK_SIZE); - chunk &= ~(AES_BLOCK_SIZE - 1); - if (chunk) - goto cfb_shortcut; - else - goto cfb_skiploop; - do { - if (iv != cdata->iv) - memcpy(cdata->iv, iv, AES_BLOCK_SIZE); - chunk = PADLOCK_CHUNK; - cfb_shortcut: /* optimize for small input */ - if (inp_misaligned) - inp = padlock_memcpy(out, in_arg, chunk); - else - inp = in_arg; - in_arg += chunk; - - iv = padlock_xcrypt_cfb(chunk / AES_BLOCK_SIZE, cdata, - out, inp); - - if (out_misaligned) - out_arg = padlock_memcpy(out_arg, out, chunk) + - chunk; - else - out = out_arg += chunk; - - nbytes -= chunk; - } while (nbytes >= AES_BLOCK_SIZE); - -cfb_skiploop: - if (nbytes) { - unsigned char *ivp = cdata->iv; - - if (iv != ivp) { - memcpy(ivp, iv, AES_BLOCK_SIZE); - iv = ivp; - } - ctx->num = nbytes; - if (cdata->cword.b.encdec) { - cdata->cword.b.encdec = 0; - padlock_reload_key(); - padlock_xcrypt_ecb(1, cdata, ivp, ivp); - cdata->cword.b.encdec = 1; - padlock_reload_key(); - while (nbytes) { - unsigned char c = *(in_arg++); - *(out_arg++) = c ^ *ivp; - *(ivp++) = c, nbytes--; - } - } else { - padlock_reload_key(); - padlock_xcrypt_ecb(1, cdata, ivp, ivp); - padlock_reload_key(); - while (nbytes) { - *ivp = *(out_arg++) = *(in_arg++) ^ *ivp; - ivp++, nbytes--; - } - } - } - - memcpy(ctx->iv, iv, AES_BLOCK_SIZE); - break; - - case EVP_CIPH_OFB_MODE: - memcpy(cdata->iv, ctx->iv, AES_BLOCK_SIZE); - chunk &= ~(AES_BLOCK_SIZE - 1); - if (chunk) do { - if (inp_misaligned) - inp = padlock_memcpy(out, in_arg, chunk); - else - inp = in_arg; - in_arg += chunk; - - padlock_xcrypt_ofb(chunk / AES_BLOCK_SIZE, cdata, - out, inp); - - if (out_misaligned) - out_arg = padlock_memcpy(out_arg, out, chunk) + - chunk; - else - out = out_arg += chunk; - - nbytes -= chunk; - chunk = PADLOCK_CHUNK; - } while (nbytes >= AES_BLOCK_SIZE); - - if (nbytes) { - unsigned char *ivp = cdata->iv; - - ctx->num = nbytes; - padlock_reload_key(); /* empirically found */ - padlock_xcrypt_ecb(1, cdata, ivp, ivp); - padlock_reload_key(); /* empirically found */ - while (nbytes) { - *(out_arg++) = *(in_arg++) ^ *ivp; - ivp++, nbytes--; - } - } - - memcpy(ctx->iv, cdata->iv, AES_BLOCK_SIZE); - break; - - default: - return 0; - } - - /* Clean the realign buffer if it was used */ - if (out_misaligned) { - volatile unsigned long *p = (void *)out; - size_t n = allocated/sizeof(*p); - while (n--) - *p++ = 0; - } - - memset(cdata->iv, 0, AES_BLOCK_SIZE); - - return 1; -} - -#endif /* OPENSSL_NO_AES */ - -/* ===== Random Number Generator ===== */ -/* - * This code is not engaged. The reason is that it does not comply - * with recommendations for VIA RNG usage for secure applications - * (posted at http://www.via.com.tw/en/viac3/c3.jsp) nor does it - * provide meaningful error control... - */ -/* Wrapper that provides an interface between the API and - the raw PadLock RNG */ -static int -padlock_rand_bytes(unsigned char *output, int count) -{ - unsigned int eax, buf; - - while (count >= 8) { - eax = padlock_xstore(output, 0); - if (!(eax & (1 << 6))) - return 0; /* RNG disabled */ - /* this ---vv--- covers DC bias, Raw Bits and String Filter */ - if (eax & (0x1F << 10)) - return 0; - if ((eax & 0x1F) == 0) - continue; /* no data, retry... */ - if ((eax & 0x1F) != 8) - return 0; /* fatal failure... */ - output += 8; - count -= 8; - } - while (count > 0) { - eax = padlock_xstore(&buf, 3); - if (!(eax & (1 << 6))) - return 0; /* RNG disabled */ - /* this ---vv--- covers DC bias, Raw Bits and String Filter */ - if (eax & (0x1F << 10)) - return 0; - if ((eax & 0x1F) == 0) - continue; /* no data, retry... */ - if ((eax & 0x1F) != 1) - return 0; /* fatal failure... */ - *output++ = (unsigned char)buf; - count--; - } - *(volatile unsigned int *)&buf = 0; - - return 1; -} - -/* Dummy but necessary function */ -static int -padlock_rand_status(void) -{ - return 1; -} - -/* Prepare structure for registration */ -static RAND_METHOD padlock_rand = { - .bytes = padlock_rand_bytes, - .pseudorand = padlock_rand_bytes, - .status = padlock_rand_status -}; - -#else /* !COMPILE_HW_PADLOCK */ -#ifndef OPENSSL_NO_DYNAMIC_ENGINE -extern int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); -extern int -bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { - return 0; -} -IMPLEMENT_DYNAMIC_CHECK_FN() -#endif -#endif /* COMPILE_HW_PADLOCK */ - -#endif /* !OPENSSL_NO_HW_PADLOCK */ -#endif /* !OPENSSL_NO_HW */ diff --git a/lib/libcrypto/engine/eng_padlock.ec b/lib/libcrypto/engine/eng_padlock.ec deleted file mode 100644 index a0e7cbd60..000000000 --- a/lib/libcrypto/engine/eng_padlock.ec +++ /dev/null @@ -1 +0,0 @@ -L PADLOCK eng_padlock_err.h eng_padlock_err.c diff --git a/lib/libcrypto/man/get_rfc3526_prime_8192.3 b/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3 similarity index 76% rename from lib/libcrypto/man/get_rfc3526_prime_8192.3 rename to lib/libcrypto/man/BN_get_rfc3526_prime_8192.3 index 5ab9571dc..abaf80ef2 100644 --- a/lib/libcrypto/man/get_rfc3526_prime_8192.3 +++ b/lib/libcrypto/man/BN_get_rfc3526_prime_8192.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: get_rfc3526_prime_8192.3,v 1.7 2023/04/02 23:33:42 tb Exp $ +.\" $OpenBSD: BN_get_rfc3526_prime_8192.3,v 1.1 2023/07/20 16:26:40 tb Exp $ .\" checked up to: OpenSSL DH_get_1024_160 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" Copyright (c) 2017 Ingo Schwarze @@ -15,18 +15,10 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 2 2023 $ -.Dt GET_RFC3526_PRIME_8192 3 +.Dd $Mdocdate: July 20 2023 $ +.Dt BN_GET_RFC3526_PRIME_8192 3 .Os .Sh NAME -.Nm get_rfc2409_prime_768 , -.Nm get_rfc2409_prime_1024 , -.Nm get_rfc3526_prime_1536 , -.Nm get_rfc3526_prime_2048 , -.Nm get_rfc3526_prime_3072 , -.Nm get_rfc3526_prime_4096 , -.Nm get_rfc3526_prime_6144 , -.Nm get_rfc3526_prime_8192 , .Nm BN_get_rfc2409_prime_768 , .Nm BN_get_rfc2409_prime_1024 , .Nm BN_get_rfc3526_prime_1536 , @@ -39,22 +31,6 @@ .Sh SYNOPSIS .In openssl/bn.h .Ft BIGNUM * -.Fn get_rfc2409_prime_768 "BIGNUM *bn" -.Ft BIGNUM * -.Fn get_rfc2409_prime_1024 "BIGNUM *bn" -.Ft BIGNUM * -.Fn get_rfc3526_prime_1536 "BIGNUM *bn" -.Ft BIGNUM * -.Fn get_rfc3526_prime_2048 "BIGNUM *bn" -.Ft BIGNUM * -.Fn get_rfc3526_prime_3072 "BIGNUM *bn" -.Ft BIGNUM * -.Fn get_rfc3526_prime_4096 "BIGNUM *bn" -.Ft BIGNUM * -.Fn get_rfc3526_prime_6144 "BIGNUM *bn" -.Ft BIGNUM * -.Fn get_rfc3526_prime_8192 "BIGNUM *bn" -.Ft BIGNUM * .Fn BN_get_rfc2409_prime_768 "BIGNUM *bn" .Ft BIGNUM * .Fn BN_get_rfc2409_prime_1024 "BIGNUM *bn" @@ -74,9 +50,6 @@ Each of these functions returns one specific constant Sophie Germain prime number .Fa p . -The names with the prefix -.Sq BN_ -are aliases for the names without that prefix. .Pp If .Fa bn @@ -153,22 +126,23 @@ information about these numbers. RFC 3526, "More Modular Exponential (MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)", defines the other six numbers. .Sh HISTORY -.Fn get_rfc2409_prime_768 , -.Fn get_rfc2409_prime_1024 , -.Fn get_rfc3526_prime_1536 , -.Fn get_rfc3526_prime_2048 , -.Fn get_rfc3526_prime_3072 , -.Fn get_rfc3526_prime_4096 , -.Fn get_rfc3526_prime_6144 , +.Fn BN_get_rfc2409_prime_768 , +.Fn BN_get_rfc2409_prime_1024 , +.Fn BN_get_rfc3526_prime_1536 , +.Fn BN_get_rfc3526_prime_2048 , +.Fn BN_get_rfc3526_prime_3072 , +.Fn BN_get_rfc3526_prime_4096 , +.Fn BN_get_rfc3526_prime_6144 , and -.Fn get_rfc3526_prime_8192 -first appeared in OpenSSL 0.9.8a and have been available since -.Ox 4.5 . -.Pp -The -.Sy BN_ -aliases first appeared in OpenSSL 1.1.0 and have been available since +.Fn BN_get_rfc3526_prime_8192 +first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +The same functions without +.Sy BN_ +prefix first appeared in OpenSSL 0.9.8a and +.Ox 4.5 ; +they were removed in +.Ox 7.4 . .Sh CAVEATS As all the memory needed for storing the numbers is dynamically allocated, the diff --git a/lib/libcrypto/man/BN_new.3 b/lib/libcrypto/man/BN_new.3 index 3a3e98379..df519c521 100644 --- a/lib/libcrypto/man/BN_new.3 +++ b/lib/libcrypto/man/BN_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_new.3,v 1.28 2023/07/09 06:45:03 tb Exp $ +.\" $OpenBSD: BN_new.3,v 1.29 2023/07/20 09:38:45 tb Exp $ .\" full merge up to: OpenSSL man3/BN_new 2457c19d Mar 6 08:43:36 2004 +0000 .\" selective merge up to: man3/BN_new 681acb31 Sep 29 13:10:34 2017 +0200 .\" full merge up to: OpenSSL man7/bn 05ea606a May 20 20:52:46 2016 -0400 @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 9 2023 $ +.Dd $Mdocdate: July 20 2023 $ .Dt BN_NEW 3 .Os .Sh NAME @@ -155,7 +155,7 @@ and sets an error code that can be obtained by .Xr BN_swap 3 , .Xr BN_zero 3 , .Xr crypto 3 , -.Xr get_rfc3526_prime_8192 3 +.Xr BN_get_rfc3526_prime_8192 3 .Sh HISTORY .Fn BN_new , .Fn BN_clear , diff --git a/lib/libcrypto/man/ECDSA_SIG_new.3 b/lib/libcrypto/man/ECDSA_SIG_new.3 index 61815128a..d278fcaaa 100644 --- a/lib/libcrypto/man/ECDSA_SIG_new.3 +++ b/lib/libcrypto/man/ECDSA_SIG_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ECDSA_SIG_new.3,v 1.17 2023/03/07 06:12:27 tb Exp $ +.\" $OpenBSD: ECDSA_SIG_new.3,v 1.18 2023/07/20 09:28:30 tb Exp $ .\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" selective merge up to: OpenSSL da4ea0cf Aug 5 16:13:24 2019 +0100 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 7 2023 $ +.Dd $Mdocdate: July 20 2023 $ .Dt ECDSA_SIG_NEW 3 .Os .Sh NAME @@ -63,12 +63,9 @@ .Nm i2d_ECDSA_SIG , .Nm d2i_ECDSA_SIG , .Nm ECDSA_size , -.Nm ECDSA_sign_setup , .Nm ECDSA_sign , -.Nm ECDSA_sign_ex , .Nm ECDSA_verify , .Nm ECDSA_do_sign , -.Nm ECDSA_do_sign_ex , .Nm ECDSA_do_verify , .Nm ECDSA_OpenSSL , .Nm ECDSA_get_default_method , @@ -121,13 +118,6 @@ .Fa "const EC_KEY *eckey" .Fc .Ft int -.Fo ECDSA_sign_setup -.Fa "EC_KEY *eckey" -.Fa "BN_CTX *ctx" -.Fa "BIGNUM **kinv" -.Fa "BIGNUM **rp" -.Fc -.Ft int .Fo ECDSA_sign .Fa "int type" .Fa "const unsigned char *dgst" @@ -137,17 +127,6 @@ .Fa "EC_KEY *eckey" .Fc .Ft int -.Fo ECDSA_sign_ex -.Fa "int type" -.Fa "const unsigned char *dgst" -.Fa "int dgstlen" -.Fa "unsigned char *sig" -.Fa "unsigned int *siglen" -.Fa "const BIGNUM *kinv" -.Fa "const BIGNUM *rp" -.Fa "EC_KEY *eckey" -.Fc -.Ft int .Fo ECDSA_verify .Fa "int type" .Fa "const unsigned char *dgst" @@ -162,14 +141,6 @@ .Fa "int dgst_len" .Fa "EC_KEY *eckey" .Fc -.Ft ECDSA_SIG* -.Fo ECDSA_do_sign_ex -.Fa "const unsigned char *dgst" -.Fa "int dgstlen" -.Fa "const BIGNUM *kinv" -.Fa "const BIGNUM *rp" -.Fa "EC_KEY *eckey" -.Fc .Ft int .Fo ECDSA_do_verify .Fa "const unsigned char *dgst" @@ -284,45 +255,13 @@ returns the maximum length of a DER-encoded ECDSA signature created with the private EC key .Fa eckey . .Pp -.Fn ECDSA_sign_setup -may be used to precompute parts of the signing operation. -.Fa eckey -is the private EC key and -.Fa ctx -is a pointer to a -.Vt BN_CTX -structure (or -.Dv NULL ) . -The precomputed values are returned in -.Fa kinv -and -.Fa rp -and can be used in a later call to -.Fa ECDSA_sign_ex -or -.Fa ECDSA_do_sign_ex . -.Pp .Fn ECDSA_sign -is a wrapper function for -.Fa ECDSA_sign_ex -with -.Fa kinv -and -.Fa rp -set to -.Dv NULL . -.Pp -.Fn ECDSA_sign_ex computes a digital signature of the .Fa dgstlen bytes hash value .Fa dgst using the private EC key -.Fa eckey -and the optional pre-computed values -.Fa kinv -and -.Fa rp . +.Fa eckey . The DER-encoded signature is stored in .Fa sig and its length is returned in @@ -352,26 +291,12 @@ The parameter is ignored. .Pp .Fn ECDSA_do_sign -is a wrapper function for -.Fn ECDSA_do_sign_ex -with -.Fa kinv -and -.Fa rp -set to -.Dv NULL . -.Pp -.Fn ECDSA_do_sign_ex computes a digital signature of the .Fa dgst_len bytes hash value .Fa dgst using the private key -.Fa eckey -and the optional pre-computed values -.Fa kinv -and -.Fa rp . +.Fa eckey . The signature is returned in a newly allocated .Vt ECDSA_SIG structure (or @@ -418,17 +343,13 @@ object if it has been set or .Dv NULL otherwise. .Pp -.Fn ECDSA_SIG_set0 , -.Fn ECDSA_sign , -.Fn ECDSA_sign_ex , +.Fn ECDSA_SIG_set0 and -.Fn ECDSA_sign_setup +.Fn ECDSA_sign return 1 if successful or 0 on error. .Pp .Fn ECDSA_do_sign -and -.Fn ECDSA_do_sign_ex -return a pointer to an allocated +returns a pointer to an allocated .Vt ECDSA_SIG structure or .Dv NULL @@ -516,12 +437,12 @@ if (ret == -1) { .Xr EC_GROUP_new 3 , .Xr EC_KEY_METHOD_new 3 , .Xr EC_KEY_new 3 , -.Xr ECDSA_set_ex_data 3 , +.Xr EC_KEY_set_ex_data 3 , .Xr EVP_DigestSignInit 3 , .Xr EVP_DigestVerifyInit 3 , .Xr RSA_new 3 .Sh STANDARDS -ANSI X9.62, US Federal Information Processing Standard FIPS 186-2 +ANSI X9.62, US Federal Information Processing Standard FIPS 186-5 (Digital Signature Standard, DSS) .Sh HISTORY .Fn ECDSA_SIG_new , @@ -529,12 +450,9 @@ ANSI X9.62, US Federal Information Processing Standard FIPS 186-2 .Fn i2d_ECDSA_SIG , .Fn d2i_ECDSA_SIG , .Fn ECDSA_size , -.Fn ECDSA_sign_setup , .Fn ECDSA_sign , -.Fn ECDSA_sign_ex , .Fn ECDSA_verify , .Fn ECDSA_do_sign , -.Fn ECDSA_do_sign_ex , .Fn ECDSA_do_verify , .Fn ECDSA_OpenSSL , .Fn ECDSA_get_default_method , diff --git a/lib/libcrypto/man/EC_KEY_METHOD_new.3 b/lib/libcrypto/man/EC_KEY_METHOD_new.3 index 383688b0e..c8efa8c73 100644 --- a/lib/libcrypto/man/EC_KEY_METHOD_new.3 +++ b/lib/libcrypto/man/EC_KEY_METHOD_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EC_KEY_METHOD_new.3,v 1.1 2019/08/16 16:15:50 schwarze Exp $ +.\" $OpenBSD: EC_KEY_METHOD_new.3,v 1.2 2023/07/20 09:28:30 tb Exp $ .\" Copyright (c) 2019 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -13,7 +13,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 16 2019 $ +.Dd $Mdocdate: July 20 2023 $ .Dt EC_KEY_METHOD_NEW 3 .Os .Sh NAME @@ -225,10 +225,9 @@ to selectively retrieve callback function pointers. and .Fn EC_KEY_METHOD_get_sign set and retrieve the functions implementing -.Xr ECDSA_sign_ex 3 , -.Xr ECDSA_sign_setup 3 , +.Xr ECDSA_sign 3 and -.Xr ECDSA_do_sign_ex 3 . +.Xr ECDSA_do_sign 3 . .Pp .Fn EC_KEY_METHOD_set_verify and diff --git a/lib/libcrypto/man/ENGINE_get_default_RSA.3 b/lib/libcrypto/man/ENGINE_get_default_RSA.3 index b04d42c18..ae6398480 100644 --- a/lib/libcrypto/man/ENGINE_get_default_RSA.3 +++ b/lib/libcrypto/man/ENGINE_get_default_RSA.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ENGINE_get_default_RSA.3,v 1.2 2018/04/18 03:39:22 schwarze Exp $ +.\" $OpenBSD: ENGINE_get_default_RSA.3,v 1.3 2023/07/20 09:28:30 tb Exp $ .\" content checked up to: .\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 .\" @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 18 2018 $ +.Dd $Mdocdate: July 20 2023 $ .Dt ENGINE_GET_DEFAULT_RSA 3 .Os .Sh NAME @@ -107,7 +107,7 @@ they are called automatically when needed, in particular from .Fn ECDH_set_method , .Fn ECDH_compute_key , .Xr ECDSA_set_method 3 , -.Xr ECDSA_do_sign_ex 3 , +.Xr ECDSA_do_sign 3 , .Xr ECDSA_do_verify 3 , .Xr DH_new 3 , .Xr EVP_CipherInit_ex 3 , diff --git a/lib/libcrypto/man/ENGINE_set_RSA.3 b/lib/libcrypto/man/ENGINE_set_RSA.3 index 0859b8f3c..4bf12defc 100644 --- a/lib/libcrypto/man/ENGINE_set_RSA.3 +++ b/lib/libcrypto/man/ENGINE_set_RSA.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ENGINE_set_RSA.3,v 1.5 2019/06/06 17:41:43 schwarze Exp $ +.\" $OpenBSD: ENGINE_set_RSA.3,v 1.6 2023/07/20 09:28:30 tb Exp $ .\" content checked up to: .\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 .\" @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 6 2019 $ +.Dd $Mdocdate: July 20 2023 $ .Dt ENGINE_SET_RSA 3 .Os .Sh NAME @@ -238,8 +238,8 @@ as shown in the following table: .It Fn ENGINE_get_RSA Ta Xr RSA_new_method 3 , Xr RSA_new 3 .It Fn ENGINE_get_DSA Ta Xr DSA_new_method 3 , Xr DSA_new 3 .It Fn ENGINE_get_ECDH Ta Fn ECDH_set_method , Fn ECDH_compute_key -.It Fn ENGINE_get_ECDSA Ta Xr ECDSA_set_method 3 , Xr ECDSA_sign_setup 3 , -.Xr ECDSA_do_sign_ex 3 , Xr ECDSA_do_verify 3 +.It Fn ENGINE_get_ECDSA Ta Xr ECDSA_set_method 3 , +.Xr ECDSA_do_sign 3 , Xr ECDSA_do_verify 3 .It Fn ENGINE_get_DH Ta Xr DH_new_method 3 , Xr DH_new 3 .It Fn ENGINE_get_RAND Ta unused .It Fn ENGINE_get_STORE Ta unused diff --git a/lib/libcrypto/man/Makefile b/lib/libcrypto/man/Makefile index 00ac9f448..adc54769f 100644 --- a/lib/libcrypto/man/Makefile +++ b/lib/libcrypto/man/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.253 2023/07/09 06:45:03 tb Exp $ +# $OpenBSD: Makefile,v 1.254 2023/07/20 16:26:40 tb Exp $ .include @@ -73,6 +73,7 @@ MAN= \ BN_cmp.3 \ BN_copy.3 \ BN_generate_prime.3 \ + BN_get_rfc3526_prime_8192.3 \ BN_kronecker.3 \ BN_mod_inverse.3 \ BN_mod_mul_montgomery.3 \ @@ -417,7 +418,6 @@ MAN= \ d2i_X509_SIG.3 \ des_read_pw.3 \ evp.3 \ - get_rfc3526_prime_8192.3 \ i2a_ASN1_STRING.3 \ i2d_CMS_bio_stream.3 \ i2d_PKCS7_bio_stream.3 \ diff --git a/lib/libcrypto/md4/md4_dgst.c b/lib/libcrypto/md4/md4_dgst.c index e6fff4893..33a1cd777 100644 --- a/lib/libcrypto/md4/md4_dgst.c +++ b/lib/libcrypto/md4/md4_dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md4_dgst.c,v 1.20 2023/07/08 10:45:57 beck Exp $ */ +/* $OpenBSD: md4_dgst.c,v 1.21 2023/07/15 15:30:43 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -146,16 +146,9 @@ void md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) { const unsigned char *data = data_; - unsigned MD32_REG_T A, B,C, D, l; -#ifndef MD32_XARRAY - /* See comment in crypto/sha/sha_locl.h for details. */ - unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, - XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; -# define X(i) XX##i -#else - MD4_LONG XX[MD4_LBLOCK]; -# define X(i) XX[i] -#endif + unsigned MD32_REG_T A, B, C, D, l; + unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, + X8, X9, X10, X11, X12, X13, X14, X15; A = c->A; B = c->B; @@ -164,88 +157,88 @@ md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) for (; num--; ) { HOST_c2l(data, l); - X( 0) = l; + X0 = l; HOST_c2l(data, l); - X( 1) = l; + X1 = l; /* Round 0 */ - R0(A, B,C, D,X( 0), 3, 0); + R0(A, B, C, D, X0, 3, 0); HOST_c2l(data, l); - X( 2) = l; - R0(D, A,B, C,X( 1), 7, 0); + X2 = l; + R0(D, A, B, C, X1, 7, 0); HOST_c2l(data, l); - X( 3) = l; - R0(C, D,A, B,X( 2), 11, 0); + X3 = l; + R0(C, D, A, B, X2, 11, 0); HOST_c2l(data, l); - X( 4) = l; - R0(B, C,D, A,X( 3), 19, 0); + X4 = l; + R0(B, C, D, A, X3, 19, 0); HOST_c2l(data, l); - X( 5) = l; - R0(A, B,C, D,X( 4), 3, 0); + X5 = l; + R0(A, B, C, D, X4, 3, 0); HOST_c2l(data, l); - X( 6) = l; - R0(D, A,B, C,X( 5), 7, 0); + X6 = l; + R0(D, A, B, C, X5, 7, 0); HOST_c2l(data, l); - X( 7) = l; - R0(C, D,A, B,X( 6), 11, 0); + X7 = l; + R0(C, D, A, B, X6, 11, 0); HOST_c2l(data, l); - X( 8) = l; - R0(B, C,D, A,X( 7), 19, 0); + X8 = l; + R0(B, C, D, A, X7, 19, 0); HOST_c2l(data, l); - X( 9) = l; - R0(A, B,C, D,X( 8), 3, 0); + X9 = l; + R0(A, B, C, D, X8, 3, 0); HOST_c2l(data, l); - X(10) = l; - R0(D, A,B, C,X( 9), 7, 0); + X10 = l; + R0(D, A,B, C,X9, 7, 0); HOST_c2l(data, l); - X(11) = l; - R0(C, D,A, B,X(10), 11, 0); + X11 = l; + R0(C, D,A, B,X10, 11, 0); HOST_c2l(data, l); - X(12) = l; - R0(B, C,D, A,X(11), 19, 0); + X12 = l; + R0(B, C,D, A,X11, 19, 0); HOST_c2l(data, l); - X(13) = l; - R0(A, B,C, D,X(12), 3, 0); + X13 = l; + R0(A, B,C, D,X12, 3, 0); HOST_c2l(data, l); - X(14) = l; - R0(D, A,B, C,X(13), 7, 0); + X14 = l; + R0(D, A,B, C,X13, 7, 0); HOST_c2l(data, l); - X(15) = l; - R0(C, D,A, B,X(14), 11, 0); - R0(B, C,D, A,X(15), 19, 0); + X15 = l; + R0(C, D,A, B,X14, 11, 0); + R0(B, C,D, A,X15, 19, 0); /* Round 1 */ - R1(A, B,C, D,X( 0), 3, 0x5A827999L); - R1(D, A,B, C,X( 4), 5, 0x5A827999L); - R1(C, D,A, B,X( 8), 9, 0x5A827999L); - R1(B, C,D, A,X(12), 13, 0x5A827999L); - R1(A, B,C, D,X( 1), 3, 0x5A827999L); - R1(D, A,B, C,X( 5), 5, 0x5A827999L); - R1(C, D,A, B,X( 9), 9, 0x5A827999L); - R1(B, C,D, A,X(13), 13, 0x5A827999L); - R1(A, B,C, D,X( 2), 3, 0x5A827999L); - R1(D, A,B, C,X( 6), 5, 0x5A827999L); - R1(C, D,A, B,X(10), 9, 0x5A827999L); - R1(B, C,D, A,X(14), 13, 0x5A827999L); - R1(A, B,C, D,X( 3), 3, 0x5A827999L); - R1(D, A,B, C,X( 7), 5, 0x5A827999L); - R1(C, D,A, B,X(11), 9, 0x5A827999L); - R1(B, C,D, A,X(15), 13, 0x5A827999L); + R1(A, B, C, D, X0, 3, 0x5A827999L); + R1(D, A, B, C, X4, 5, 0x5A827999L); + R1(C, D, A, B, X8, 9, 0x5A827999L); + R1(B, C, D, A, X12, 13, 0x5A827999L); + R1(A, B, C, D, X1, 3, 0x5A827999L); + R1(D, A, B, C, X5, 5, 0x5A827999L); + R1(C, D, A, B, X9, 9, 0x5A827999L); + R1(B, C, D, A, X13, 13, 0x5A827999L); + R1(A, B, C, D, X2, 3, 0x5A827999L); + R1(D, A, B, C, X6, 5, 0x5A827999L); + R1(C, D, A, B, X10, 9, 0x5A827999L); + R1(B, C, D, A, X14, 13, 0x5A827999L); + R1(A, B, C, D, X3, 3, 0x5A827999L); + R1(D, A, B, C, X7, 5, 0x5A827999L); + R1(C, D, A, B, X11, 9, 0x5A827999L); + R1(B, C, D, A, X15, 13, 0x5A827999L); /* Round 2 */ - R2(A, B,C, D,X( 0), 3, 0x6ED9EBA1L); - R2(D, A,B, C,X( 8), 9, 0x6ED9EBA1L); - R2(C, D,A, B,X( 4), 11, 0x6ED9EBA1L); - R2(B, C,D, A,X(12), 15, 0x6ED9EBA1L); - R2(A, B,C, D,X( 2), 3, 0x6ED9EBA1L); - R2(D, A,B, C,X(10), 9, 0x6ED9EBA1L); - R2(C, D,A, B,X( 6), 11, 0x6ED9EBA1L); - R2(B, C,D, A,X(14), 15, 0x6ED9EBA1L); - R2(A, B,C, D,X( 1), 3, 0x6ED9EBA1L); - R2(D, A,B, C,X( 9), 9, 0x6ED9EBA1L); - R2(C, D,A, B,X( 5), 11, 0x6ED9EBA1L); - R2(B, C,D, A,X(13), 15, 0x6ED9EBA1L); - R2(A, B,C, D,X( 3), 3, 0x6ED9EBA1L); - R2(D, A,B, C,X(11), 9, 0x6ED9EBA1L); - R2(C, D,A, B,X( 7), 11, 0x6ED9EBA1L); - R2(B, C,D, A,X(15), 15, 0x6ED9EBA1L); + R2(A, B, C, D, X0, 3, 0x6ED9EBA1L); + R2(D, A, B, C, X8, 9, 0x6ED9EBA1L); + R2(C, D, A, B, X4, 11, 0x6ED9EBA1L); + R2(B, C, D, A, X12, 15, 0x6ED9EBA1L); + R2(A, B, C, D, X2, 3, 0x6ED9EBA1L); + R2(D, A, B, C, X10, 9, 0x6ED9EBA1L); + R2(C, D, A, B, X6, 11, 0x6ED9EBA1L); + R2(B, C, D, A, X14, 15, 0x6ED9EBA1L); + R2(A, B, C, D, X1, 3, 0x6ED9EBA1L); + R2(D, A, B, C, X9, 9, 0x6ED9EBA1L); + R2(C, D, A, B, X5, 11, 0x6ED9EBA1L); + R2(B, C, D, A, X13, 15, 0x6ED9EBA1L); + R2(A, B, C, D, X3, 3, 0x6ED9EBA1L); + R2(D, A, B, C, X11, 9, 0x6ED9EBA1L); + R2(C, D, A, B, X7, 11, 0x6ED9EBA1L); + R2(B, C, D, A, X15, 15, 0x6ED9EBA1L); A = c->A += A; B = c->B += B; diff --git a/lib/libcrypto/md5/md5_dgst.c b/lib/libcrypto/md5/md5_dgst.c index b0eb47219..3cd4b1ba7 100644 --- a/lib/libcrypto/md5/md5_dgst.c +++ b/lib/libcrypto/md5/md5_dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5_dgst.c,v 1.18 2023/07/08 10:45:57 beck Exp $ */ +/* $OpenBSD: md5_dgst.c,v 1.19 2023/07/15 15:37:05 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -166,16 +166,9 @@ void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num) { const unsigned char *data = data_; - unsigned MD32_REG_T A, B,C, D, l; -#ifndef MD32_XARRAY - /* See comment in crypto/sha/sha_locl.h for details. */ - unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, - XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; -# define X(i) XX##i -#else - MD5_LONG XX[MD5_LBLOCK]; -# define X(i) XX[i] -#endif + unsigned MD32_REG_T A, B, C, D, l; + unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, + X8, X9, X10, X11, X12, X13, X14, X15; A = c->A; B = c->B; @@ -184,105 +177,105 @@ md5_block_data_order(MD5_CTX *c, const void *data_, size_t num) for (; num--; ) { HOST_c2l(data, l); - X( 0) = l; + X0 = l; HOST_c2l(data, l); - X( 1) = l; + X1 = l; /* Round 0 */ - R0(A, B,C, D,X( 0), 7, 0xd76aa478L); + R0(A, B, C, D, X0, 7, 0xd76aa478L); HOST_c2l(data, l); - X( 2) = l; - R0(D, A,B, C,X( 1), 12, 0xe8c7b756L); + X2 = l; + R0(D, A, B, C, X1, 12, 0xe8c7b756L); HOST_c2l(data, l); - X( 3) = l; - R0(C, D,A, B,X( 2), 17, 0x242070dbL); + X3 = l; + R0(C, D, A, B, X2, 17, 0x242070dbL); HOST_c2l(data, l); - X( 4) = l; - R0(B, C,D, A,X( 3), 22, 0xc1bdceeeL); + X4 = l; + R0(B, C, D, A, X3, 22, 0xc1bdceeeL); HOST_c2l(data, l); - X( 5) = l; - R0(A, B,C, D,X( 4), 7, 0xf57c0fafL); + X5 = l; + R0(A, B, C, D, X4, 7, 0xf57c0fafL); HOST_c2l(data, l); - X( 6) = l; - R0(D, A,B, C,X( 5), 12, 0x4787c62aL); + X6 = l; + R0(D, A, B, C, X5, 12, 0x4787c62aL); HOST_c2l(data, l); - X( 7) = l; - R0(C, D,A, B,X( 6), 17, 0xa8304613L); + X7 = l; + R0(C, D, A, B, X6, 17, 0xa8304613L); HOST_c2l(data, l); - X( 8) = l; - R0(B, C,D, A,X( 7), 22, 0xfd469501L); + X8 = l; + R0(B, C, D, A, X7, 22, 0xfd469501L); HOST_c2l(data, l); - X( 9) = l; - R0(A, B,C, D,X( 8), 7, 0x698098d8L); + X9 = l; + R0(A, B, C, D, X8, 7, 0x698098d8L); HOST_c2l(data, l); - X(10) = l; - R0(D, A,B, C,X( 9), 12, 0x8b44f7afL); + X10 = l; + R0(D, A, B, C, X9, 12, 0x8b44f7afL); HOST_c2l(data, l); - X(11) = l; - R0(C, D,A, B,X(10), 17, 0xffff5bb1L); + X11 = l; + R0(C, D, A, B, X10, 17, 0xffff5bb1L); HOST_c2l(data, l); - X(12) = l; - R0(B, C,D, A,X(11), 22, 0x895cd7beL); + X12 = l; + R0(B, C, D, A, X11, 22, 0x895cd7beL); HOST_c2l(data, l); - X(13) = l; - R0(A, B,C, D,X(12), 7, 0x6b901122L); + X13 = l; + R0(A, B, C, D, X12, 7, 0x6b901122L); HOST_c2l(data, l); - X(14) = l; - R0(D, A,B, C,X(13), 12, 0xfd987193L); + X14 = l; + R0(D, A, B, C, X13, 12, 0xfd987193L); HOST_c2l(data, l); - X(15) = l; - R0(C, D,A, B,X(14), 17, 0xa679438eL); - R0(B, C,D, A,X(15), 22, 0x49b40821L); + X15 = l; + R0(C, D, A, B, X14, 17, 0xa679438eL); + R0(B, C, D, A, X15, 22, 0x49b40821L); /* Round 1 */ - R1(A, B,C, D,X( 1), 5, 0xf61e2562L); - R1(D, A,B, C,X( 6), 9, 0xc040b340L); - R1(C, D,A, B,X(11), 14, 0x265e5a51L); - R1(B, C,D, A,X( 0), 20, 0xe9b6c7aaL); - R1(A, B,C, D,X( 5), 5, 0xd62f105dL); - R1(D, A,B, C,X(10), 9, 0x02441453L); - R1(C, D,A, B,X(15), 14, 0xd8a1e681L); - R1(B, C,D, A,X( 4), 20, 0xe7d3fbc8L); - R1(A, B,C, D,X( 9), 5, 0x21e1cde6L); - R1(D, A,B, C,X(14), 9, 0xc33707d6L); - R1(C, D,A, B,X( 3), 14, 0xf4d50d87L); - R1(B, C,D, A,X( 8), 20, 0x455a14edL); - R1(A, B,C, D,X(13), 5, 0xa9e3e905L); - R1(D, A,B, C,X( 2), 9, 0xfcefa3f8L); - R1(C, D,A, B,X( 7), 14, 0x676f02d9L); - R1(B, C,D, A,X(12), 20, 0x8d2a4c8aL); + R1(A, B, C, D, X1, 5, 0xf61e2562L); + R1(D, A, B, C, X6, 9, 0xc040b340L); + R1(C, D, A, B, X11, 14, 0x265e5a51L); + R1(B, C, D, A, X0, 20, 0xe9b6c7aaL); + R1(A, B, C, D, X5, 5, 0xd62f105dL); + R1(D, A, B, C, X10, 9, 0x02441453L); + R1(C, D, A, B, X15, 14, 0xd8a1e681L); + R1(B, C, D, A, X4, 20, 0xe7d3fbc8L); + R1(A, B, C, D, X9, 5, 0x21e1cde6L); + R1(D, A, B, C, X14, 9, 0xc33707d6L); + R1(C, D, A, B, X3, 14, 0xf4d50d87L); + R1(B, C, D, A, X8, 20, 0x455a14edL); + R1(A, B, C, D, X13, 5, 0xa9e3e905L); + R1(D, A, B, C, X2, 9, 0xfcefa3f8L); + R1(C, D, A, B, X7, 14, 0x676f02d9L); + R1(B, C, D, A, X12, 20, 0x8d2a4c8aL); /* Round 2 */ - R2(A, B,C, D,X( 5), 4, 0xfffa3942L); - R2(D, A,B, C,X( 8), 11, 0x8771f681L); - R2(C, D,A, B,X(11), 16, 0x6d9d6122L); - R2(B, C,D, A,X(14), 23, 0xfde5380cL); - R2(A, B,C, D,X( 1), 4, 0xa4beea44L); - R2(D, A,B, C,X( 4), 11, 0x4bdecfa9L); - R2(C, D,A, B,X( 7), 16, 0xf6bb4b60L); - R2(B, C,D, A,X(10), 23, 0xbebfbc70L); - R2(A, B,C, D,X(13), 4, 0x289b7ec6L); - R2(D, A,B, C,X( 0), 11, 0xeaa127faL); - R2(C, D,A, B,X( 3), 16, 0xd4ef3085L); - R2(B, C,D, A,X( 6), 23, 0x04881d05L); - R2(A, B,C, D,X( 9), 4, 0xd9d4d039L); - R2(D, A,B, C,X(12), 11, 0xe6db99e5L); - R2(C, D,A, B,X(15), 16, 0x1fa27cf8L); - R2(B, C,D, A,X( 2), 23, 0xc4ac5665L); + R2(A, B, C, D, X5, 4, 0xfffa3942L); + R2(D, A, B, C, X8, 11, 0x8771f681L); + R2(C, D, A, B, X11, 16, 0x6d9d6122L); + R2(B, C, D, A, X14, 23, 0xfde5380cL); + R2(A, B, C, D, X1, 4, 0xa4beea44L); + R2(D, A, B, C, X4, 11, 0x4bdecfa9L); + R2(C, D, A, B, X7, 16, 0xf6bb4b60L); + R2(B, C, D, A, X10, 23, 0xbebfbc70L); + R2(A, B, C, D, X13, 4, 0x289b7ec6L); + R2(D, A, B, C, X0, 11, 0xeaa127faL); + R2(C, D, A, B, X3, 16, 0xd4ef3085L); + R2(B, C, D, A, X6, 23, 0x04881d05L); + R2(A, B, C, D, X9, 4, 0xd9d4d039L); + R2(D, A, B, C, X12, 11, 0xe6db99e5L); + R2(C, D, A, B, X15, 16, 0x1fa27cf8L); + R2(B, C, D, A, X2, 23, 0xc4ac5665L); /* Round 3 */ - R3(A, B,C, D,X( 0), 6, 0xf4292244L); - R3(D, A,B, C,X( 7), 10, 0x432aff97L); - R3(C, D,A, B,X(14), 15, 0xab9423a7L); - R3(B, C,D, A,X( 5), 21, 0xfc93a039L); - R3(A, B,C, D,X(12), 6, 0x655b59c3L); - R3(D, A,B, C,X( 3), 10, 0x8f0ccc92L); - R3(C, D,A, B,X(10), 15, 0xffeff47dL); - R3(B, C,D, A,X( 1), 21, 0x85845dd1L); - R3(A, B,C, D,X( 8), 6, 0x6fa87e4fL); - R3(D, A,B, C,X(15), 10, 0xfe2ce6e0L); - R3(C, D,A, B,X( 6), 15, 0xa3014314L); - R3(B, C,D, A,X(13), 21, 0x4e0811a1L); - R3(A, B,C, D,X( 4), 6, 0xf7537e82L); - R3(D, A,B, C,X(11), 10, 0xbd3af235L); - R3(C, D,A, B,X( 2), 15, 0x2ad7d2bbL); - R3(B, C,D, A,X( 9), 21, 0xeb86d391L); + R3(A, B, C, D, X0, 6, 0xf4292244L); + R3(D, A, B, C, X7, 10, 0x432aff97L); + R3(C, D, A, B, X14, 15, 0xab9423a7L); + R3(B, C, D, A, X5, 21, 0xfc93a039L); + R3(A, B, C, D, X12, 6, 0x655b59c3L); + R3(D, A, B, C, X3, 10, 0x8f0ccc92L); + R3(C, D, A, B, X10, 15, 0xffeff47dL); + R3(B, C, D, A, X1, 21, 0x85845dd1L); + R3(A, B, C, D, X8, 6, 0x6fa87e4fL); + R3(D, A, B, C, X15, 10, 0xfe2ce6e0L); + R3(C, D, A, B, X6, 15, 0xa3014314L); + R3(B, C, D, A, X13, 21, 0x4e0811a1L); + R3(A, B, C, D, X4, 6, 0xf7537e82L); + R3(D, A, B, C, X11, 10, 0xbd3af235L); + R3(C, D, A, B, X2, 15, 0x2ad7d2bbL); + R3(B, C, D, A, X9, 21, 0xeb86d391L); A = c->A += A; B = c->B += B; diff --git a/lib/libssl/bio_ssl.c b/lib/libssl/bio_ssl.c index 08e47dbfa..6dd169960 100644 --- a/lib/libssl/bio_ssl.c +++ b/lib/libssl/bio_ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ssl.c,v 1.39 2023/07/08 16:40:13 beck Exp $ */ +/* $OpenBSD: bio_ssl.c,v 1.40 2023/07/19 13:34:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -577,7 +577,7 @@ BIO_ssl_copy_session_id(BIO *t, BIO *f) return (0); return (1); } -LSSL_ALIAS(BIO_new_ssl_connect); +LSSL_ALIAS(BIO_ssl_copy_session_id); void BIO_ssl_shutdown(BIO *b) diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c index b1169b024..76fcfdec8 100644 --- a/lib/libssl/ssl_lib.c +++ b/lib/libssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.311 2023/07/08 16:40:13 beck Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.312 2023/07/19 13:34:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -3313,6 +3313,7 @@ void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type, int val) { return (ssl->info_callback); } +LSSL_ALIAS(SSL_get_info_callback); int SSL_state(const SSL *ssl) diff --git a/lib/libssl/ssl_pkt.c b/lib/libssl/ssl_pkt.c index 728ac141e..2c33c4538 100644 --- a/lib/libssl/ssl_pkt.c +++ b/lib/libssl/ssl_pkt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_pkt.c,v 1.65 2022/11/26 16:08:56 tb Exp $ */ +/* $OpenBSD: ssl_pkt.c,v 1.66 2023/07/11 17:02:47 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -536,7 +536,6 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) SSL_SESSION *sess = s->session; int need_empty_fragment = 0; size_t align, out_len; - uint16_t version; CBB cbb; int ret; @@ -568,16 +567,6 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) if (len == 0) return 0; - /* - * Some servers hang if initial client hello is larger than 256 - * bytes and record version number > TLS 1.0. - */ - version = s->version; - if (s->s3->hs.state == SSL3_ST_CW_CLNT_HELLO_B && - !s->renegotiate && - s->s3->hs.our_max_tls_version > TLS1_VERSION) - version = TLS1_VERSION; - /* * Countermeasure against known-IV weakness in CBC ciphersuites * (see http://www.openssl.org/~bodo/tls-cbc.txt). Note that this @@ -604,7 +593,7 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) if (!CBB_init_fixed(&cbb, wb->buf + align, wb->len - align)) goto err; - tls12_record_layer_set_version(s->rl, version); + tls12_record_layer_set_version(s->rl, s->version); if (need_empty_fragment) { if (!tls12_record_layer_seal_record(s->rl, type, diff --git a/libexec/ld.so/ldd/ldd.c b/libexec/ld.so/ldd/ldd.c index a7a874e07..860f46318 100644 --- a/libexec/ld.so/ldd/ldd.c +++ b/libexec/ld.so/ldd/ldd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldd.c,v 1.22 2017/10/27 16:47:08 mpi Exp $ */ +/* $OpenBSD: ldd.c,v 1.23 2023/07/13 19:04:50 jasper Exp $ */ /* * Copyright (c) 2001 Artur Grabowski * All rights reserved. @@ -117,19 +117,25 @@ doit(char *name) close(fd); return 1; } + if (read(fd, &ehdr, sizeof(ehdr)) < 0) { warn("read(%s)", name); close(fd); return 1; } - if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) || - ehdr.e_machine != ELF_TARG_MACH) { + if (!IS_ELF(ehdr) || ehdr.e_machine != ELF_TARG_MACH) { warnx("%s: not an ELF executable", name); close(fd); return 1; } + if (ehdr.e_phnum == 0 || ehdr.e_phentsize == 0) { + warnx("%s: missing program header", name); + close(fd); + return 1; + } + if ((phdr = reallocarray(NULL, ehdr.e_phnum, sizeof(Elf_Phdr))) == NULL) err(1, "reallocarray"); size = ehdr.e_phnum * sizeof(Elf_Phdr); diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c index 687520746..8e2f44c19 100644 --- a/libexec/ld.so/library.c +++ b/libexec/ld.so/library.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library.c,v 1.90 2023/01/29 20:30:56 gnezdo Exp $ */ +/* $OpenBSD: library.c,v 1.91 2023/07/12 19:49:06 jasper Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -113,6 +113,7 @@ _dl_tryload_shlib(const char *libname, int type, int flags, int nodelete) Elf_Phdr *ptls = NULL; struct stat sb; +#define powerof2(x) ((((x) - 1) & (x)) == 0) #define ROUND_PG(x) (((x) + align) & ~(align)) #define TRUNC_PG(x) ((x) & ~(align)) @@ -160,6 +161,14 @@ _dl_tryload_shlib(const char *libname, int type, int flags, int nodelete) */ phdp = (Elf_Phdr *)(hbuf + ehdr->e_phoff); for (i = 0; i < ehdr->e_phnum; i++, phdp++) { + if (phdp->p_align > 1 && !powerof2(phdp->p_align)) { + _dl_printf("%s: ld.so invalid ELF input %s.\n", + __progname, libname); + _dl_close(libfile); + _dl_errno = DL_CANT_MMAP; + return(0); + } + switch (phdp->p_type) { case PT_LOAD: if (phdp->p_vaddr < minva) diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c index 93019a039..57775382b 100644 --- a/libexec/ld.so/library_mquery.c +++ b/libexec/ld.so/library_mquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_mquery.c,v 1.70 2023/01/29 20:30:56 gnezdo Exp $ */ +/* $OpenBSD: library_mquery.c,v 1.71 2023/07/12 19:49:06 jasper Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -118,6 +118,7 @@ _dl_tryload_shlib(const char *libname, int type, int flags, int nodelete) char hbuf[4096], *exec_start; size_t exec_size; +#define powerof2(x) ((((x) - 1) & (x)) == 0) #define ROUND_PG(x) (((x) + align) & ~(align)) #define TRUNC_PG(x) ((x) & ~(align)) @@ -171,6 +172,14 @@ _dl_tryload_shlib(const char *libname, int type, int flags, int nodelete) */ phdp = (Elf_Phdr *)(hbuf + ehdr->e_phoff); for (i = 0; i < ehdr->e_phnum; i++, phdp++) { + if (phdp->p_align > 1 && !powerof2(phdp->p_align)) { + _dl_printf("%s: ld.so invalid ELF input %s.\n", + __progname, libname); + _dl_close(libfile); + _dl_errno = DL_CANT_MMAP; + return(0); + } + switch (phdp->p_type) { case PT_LOAD: off = (phdp->p_vaddr & align); diff --git a/regress/lib/libcrypto/bn/bn_print.c b/regress/lib/libcrypto/bn/bn_print.c index 24f261d92..47def8577 100644 --- a/regress/lib/libcrypto/bn/bn_print.c +++ b/regress/lib/libcrypto/bn/bn_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_print.c,v 1.3 2023/07/07 07:47:25 tb Exp $ */ +/* $OpenBSD: bn_print.c,v 1.4 2023/07/10 20:21:37 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler @@ -139,6 +139,11 @@ const struct print_test { .want = " mana mana\n" " 00:80:00:00:00:00:00:00:00:00\n", }, + { + .desc = "high bit of first nibble is set for negative number", + .want = " mana mana (Negative)\n" + " 00:80:00:00:00:00:00:00:00:00\n", + }, }; #define N_TESTCASES (sizeof(bn_print_tests) / sizeof(bn_print_tests[0])) @@ -281,6 +286,13 @@ main(void) test = &bn_print_tests[testcase++]; failed |= bn_print_testcase(bn, test); + /* high bit of first nibble is set for negative number. */ + BN_set_negative(bn, 1); + if (testcase >= N_TESTCASES) + errx(1, "Too many tests"); + test = &bn_print_tests[testcase++]; + failed |= bn_print_testcase(bn, test); + if (testcase != N_TESTCASES) { warnx("Not all tests run"); failed |= 1; diff --git a/regress/lib/libcrypto/ecdh/Makefile b/regress/lib/libcrypto/ecdh/Makefile index 202e125ca..53ec37d13 100644 --- a/regress/lib/libcrypto/ecdh/Makefile +++ b/regress/lib/libcrypto/ecdh/Makefile @@ -1,6 +1,8 @@ -# $OpenBSD: Makefile,v 1.5 2021/05/10 20:41:44 tb Exp $ +# $OpenBSD: Makefile,v 1.6 2023/07/15 19:51:13 tb Exp $ + +PROGS = ecdhtest +PROGS += ecc_cdh -PROG= ecdhtest LDADD= -lcrypto DPADD= ${LIBCRYPTO} WARNINGS= Yes diff --git a/regress/lib/libcrypto/ecdh/ecc_cdh.c b/regress/lib/libcrypto/ecdh/ecc_cdh.c new file mode 100644 index 000000000..0333cf1e8 --- /dev/null +++ b/regress/lib/libcrypto/ecdh/ecc_cdh.c @@ -0,0 +1,2506 @@ +/* $OpenBSD: ecc_cdh.c,v 1.2 2023/07/16 08:25:41 tb Exp $ */ + +/* + * Copyright (c) 2023 Theo Buehler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * ECC-CDH test vectors extracted from version 14.1 of Component-Testing#ECCCDH + * https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/ + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +static const struct ecc_cdh_test { + int nid; + const char *peer_x; + const char *peer_y; + const char *priv; + const char *pub_x; + const char *pub_y; + const char *want; +} ecc_cdh_tests[] = { + { + .nid = NID_X9_62_prime192v1, + .peer_x = "42ea6dd9969dd2a61fea1aac7f8e98edcc896c6e55857cc0", + .peer_y = "dfbe5d7c61fac88b11811bde328e8a0d12bf01a9d204b523", + .priv = "f17d3fea367b74d340851ca4270dcb24c271f445bed9d527", + .pub_x = "b15053401f57285637ec324c1cd2139e3a67de3739234b37", + .pub_y = "f269c158637482aad644cd692dd1d3ef2c8a7c49e389f7f6", + .want = "803d8ab2e5b6e6fca715737c3a82f7ce3c783124f6d51cd0", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "deb5712fa027ac8d2f22c455ccb73a91e17b6512b5e030e7", + .peer_y = "7e2690a02cc9b28708431a29fb54b87b1f0c14e011ac2125", + .priv = "56e853349d96fe4c442448dacb7cf92bb7a95dcf574a9bd5", + .pub_x = "c00d435716ffea53fd8c162792414c37665187e582716539", + .pub_y = "ab711c62aa71a5a18e8a3c48f89dc6fa52fac0108e52a8a0", + .want = "c208847568b98835d7312cef1f97f7aa298283152313c29d", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "4edaa8efc5a0f40f843663ec5815e7762dddc008e663c20f", + .peer_y = "0a9f8dc67a3e60ef6d64b522185d03df1fc0adfd42478279", + .priv = "c6ef61fe12e80bf56f2d3f7d0bb757394519906d55500949", + .pub_x = "e184bc182482f3403c8787b83842477467fcd011db0f6c64", + .pub_y = "f9d1c14142f40de8639db97d51a63d2cce1007ccf773cdcb", + .want = "87229107047a3b611920d6e3b2c0c89bea4f49412260b8dd", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "8887c276edeed3e9e866b46d58d895c73fbd80b63e382e88", + .peer_y = "04c5097ba6645e16206cfb70f7052655947dd44a17f1f9d5", + .priv = "e6747b9c23ba7044f38ff7e62c35e4038920f5a0163d3cda", + .pub_x = "2b838dbe73735f37a39a78d3195783d26991e86ff4d92d1a", + .pub_y = "60d344942274489f98903b2e7f93f8d197fc9ae60a0ed53a", + .want = "eec0bed8fc55e1feddc82158fd6dc0d48a4d796aaf47d46c", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "0d045f30254adc1fcefa8a5b1f31bf4e739dd327cd18d594", + .peer_y = "542c314e41427c08278a08ce8d7305f3b5b849c72d8aff73", + .priv = "beabedd0154a1afcfc85d52181c10f5eb47adc51f655047d", + .pub_x = "1f65cf6e8978e1c1bc10bb61a7db311de310088c8cf9768b", + .pub_y = "f7d438168e7f42ab14b16af53a7a2f646ff40b53d74cbcc7", + .want = "716e743b1b37a2cd8479f0a3d5a74c10ba2599be18d7e2f4", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "fb35ca20d2e96665c51b98e8f6eb3d79113508d8bccd4516", + .peer_y = "368eec0d5bfb847721df6aaff0e5d48c444f74bf9cd8a5a7", + .priv = "cf70354226667321d6e2baf40999e2fd74c7a0f793fa8699", + .pub_x = "5f4844ffcce61005d24f737db98675e92f7b6543aeb6106c", + .pub_y = "5424f598139215d389b6b12b86d58014857f2ddadb540f51", + .want = "f67053b934459985a315cb017bf0302891798d45d0e19508", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "824752960c1307e5f13a83da21c7998ca8b5b00b9549f6d0", + .peer_y = "bc52d91e234363bc32ee0b6778f25cd8c1847510f4348b94", + .priv = "fe942515237fffdd7b4eb5c64909eee4856a076cdf12bae2", + .pub_x = "e6369df79b207b8b8679f7c869cfc264859d1ab55aa401e8", + .pub_y = "1f99c71f801a30b52f74da6e5e6dbb62ee4c5da1090cc020", + .want = "75822971193edd472bf30151a782619c55ad0b279c9303dd", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "10bb57020291141981f833b4749e5611034b308e84011d21", + .peer_y = "e1cacd6b7bd17ed8ddb50b6aee0654c35f2d0eddc1cffcf6", + .priv = "33fed10492afa5bea0333c0af12cac940c4d222455bcd0fe", + .pub_x = "ef0b28afc41637d737f42e4c8aaceadc84ba2e0b849ca18c", + .pub_y = "57797942e552173bba17f73278e029f42335068bd770ddf2", + .want = "67cba2cbb69ee78bf1abafb0e6fbe33fa2094c128d59652d", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "5192fce4185a7758ea1bc56e0e4f4e8b2dce32348d0dced1", + .peer_y = "20989981beaaf0006d88a96e7971a2fa3a33ba46047fc7ba", + .priv = "f3557c5d70b4c7954960c33568776adbe8e43619abe26b13", + .pub_x = "d70112c5f0f0844386494ac1ad99dce2214134176ebfb9af", + .pub_y = "d3c187a038510ab31d459e2b7af1a380dd7576af06267548", + .want = "cf99a2770a386ca0137d1eca0a226e484297ac3c513f3631", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "26d019dbe279ead01eed143a91601ada26e2f42225b1c62b", + .peer_y = "6ca653f08272e0386fc9421fbd580093d7ae6301bca94476", + .priv = "586cfba1c6e81766ed52828f177b1be14ebbc5b83348c311", + .pub_x = "58b3c63e56bec9d696bf9a88df2873738391f76368aa2b49", + .pub_y = "5776773b261faf7ba2fdc4fe43b92c0b1c7a2fd054a43650", + .want = "576331e2b4fb38a112810e1529834de8307fb0a0d2756877", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "539bc40fe20a0fb267888b647b03eaaf6ec20c02a1e1f8c8", + .peer_y = "69095e5bb7b4d44c3278a7ee6beca397c45246da9a34c8be", + .priv = "cad8100603a4f65be08d8fc8a1b7e884c5ff65deb3c96d99", + .pub_x = "b7fcc0f52c7a411edbed39e10bf02b6ae0f26614c6b325a2", + .pub_y = "47483b26eb67776de2b93ab7119d5447573739e3d55e72fb", + .want = "902f4501916a0dd945554c3a37b3d780d375a6da713197c4", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "5d343ddb96318fb4794d10f6c573f99fee5d0d57b996250f", + .peer_y = "99fbdf9d97dd88ad410235dac36e5b92ce2824b8e587a82c", + .priv = "1edd879cc5c79619cae6c73a691bd5a0395c0ef3b356fcd2", + .pub_x = "6ce6adb2c30808f590048c33dffad4524ebf7a5fd39b747b", + .pub_y = "4966bd2f3d00569b4d4c0409fbd7a2db752f6d09bca8c25f", + .want = "46e4de335054d429863218ae33636fc9b89c628b64b506c7", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "8d3db9bdce137ffbfb891388c37df6c0cbc90aa5e5376220", + .peer_y = "135d30b5cb660eef8764ffc744f15c1b5d6dc06ba4416d37", + .priv = "460e452273fe1827602187ad3bebee65cb84423bb4f47537", + .pub_x = "d1bd3a3efabf4767fe6380bdf0dbf49d52d4cf0cbb89404c", + .pub_y = "c150c2b4c8b3aa35f765f847e4f7f8fd8704d241a181ee99", + .want = "1bfe9e5a20ac7a38d8f605b425bb9030be31ef97c101c76c", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "9e0a6949519c7f5be68c0433c5fdf13064aa13fb29483dc3", + .peer_y = "e1c8ba63e1f471db23185f50d9c871edea21255b3a63b4b7", + .priv = "b970365008456f8758ecc5a3b33cf3ae6a8d568107a52167", + .pub_x = "c1b8610c8c63f8d4abda093b9a11a566044bf65c6faa8999", + .pub_y = "a5bc4b3ca095382e9738aee95fe9479b17879b3ad5295559", + .want = "0e8c493a4adc445dc9288a3b9b272599224054592d7265b3", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "be088238902e9939b3d054eeeb8492daf4bdcf09a2ab77f1", + .peer_y = "58d6749a3a923dc80440f2661fd35b651617e65294b46375", + .priv = "59c15b8a2464e41dfe4371c7f7dadf470ae425544f8113bd", + .pub_x = "1fe776f73567b6ac0b0d6764164de6c5be751ba8d1ff455e", + .pub_y = "4c160bf38afb2b71f684261664115ce874553e8b059432d2", + .want = "0f1991086b455ded6a1c4146f7bf59fe9b495de566ebc6bf", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "bf5ae05025e1be617e666d87a4168363873d5761b376b503", + .peer_y = "e1e6e38b372b6bee0ff5b3502d83735e3b2c26825e4f0fcc", + .priv = "a6e9b885c66b959d1fc2708d591b6d3228e49eb98f726d61", + .pub_x = "632bb7651dbf49dde9dd125d13fb234e06617723beed3d1b", + .pub_y = "f4ad5209638488397c5f44f994dd7479807e79f4887d2e71", + .want = "b30f2127c34df35aaa91dbf0bbe15798e799a03ed11698c1", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "6cc4feed84c7ab0d09005d660ed34de6955a9461c4138d11", + .peer_y = "31225f33864ed48da06fa45a913b46cf42557742e35085e6", + .priv = "bdb754096ffbfbd8b0f3cb046ccb7ca149c4e7192067a3ee", + .pub_x = "d9c098d421d741f6faab116f3e4731d28c5558e19fe112a1", + .pub_y = "38d4dc48ccdb1d3ed8d31fd06784a4f87a68aec1cbd5b08f", + .want = "64a5c246599d3e8177a2402a1110eb81e6c456ab4edb5127", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "36157315bee7afedded58c4e8ba14d3421c401e51135bcc9", + .peer_y = "37c297ca703f77c52bb062d8ce971db84097ba0c753a418f", + .priv = "d5bcf2534dafc3d99964c7bd63ab7bd15999fe56dd969c42", + .pub_x = "fda1d5d28d6fe0e7909d6a8bafa7824db5572ab92ffe7de6", + .pub_y = "134a297c1d9c8bbab249abacd951ed11e5a99f92e7991572", + .want = "017b8ca53c82fab163da2ab783966a39e061b32c8cfa334d", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "98464d47f0256f8292e027e8c92582ea77cf9051f5ce8e5d", + .peer_y = "449552ef7578be96236fe5ed9d0643c0bb6c5a9134b0108d", + .priv = "43d4b9df1053be5b4268104c02244d3bf9594b010b46a8b2", + .pub_x = "c3020b7091463d788f1f1d76f7cfeec82ecdb3b7d99c345c", + .pub_y = "9a7710d5179591d8f3df0aa122301768ae7db7eee2d7f583", + .want = "340ef3db3dbebdd91c62c3d4e1a3da2c7c52a3338b865259", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "563eb66c334cf6f123bf04c7803b48a3110214237e983bf5", + .peer_y = "0f351104819199ef07c9a6051d20758f3af79027ea66a53f", + .priv = "94cac2c2ca714746401670d94edbf3f677867b5a03bee7ad", + .pub_x = "b18554a2e743ef0aa2f040987c4c451004e096df3d80ddae", + .pub_y = "6e3e2c618f896e36ba620077684b70a05ffb79bf5e6c7640", + .want = "2162144921df5103d0e6a650fb13fd246f4738d0896ce92f", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "86828c4ac92b5507618aec7873a1d4fc6543c5be33cf3078", + .peer_y = "b22ca72437545e10d6d4f052422eb898b737a4b8543ee550", + .priv = "2a3a9e33c8cc3107a9f9265c3bdea1206570e86f92ac7014", + .pub_x = "a7ba38be1bc669dd23ccfcee0645b1f0db8cf942deafaeb6", + .pub_y = "b82db79d80cd0e37f28d4163adc389dee8fc7797b5c9831b", + .want = "4c69e7feed4b11159adfc16a6047a92572ea44e0740b23af", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "6700a102437781a9581da2bc25ced5abf419da91d3c803df", + .peer_y = "71396c9cf08bcd91854e3e6e42d8c657ce0f27ab77a9dc4b", + .priv = "4a6b78a98ac98fa8e99a8ece08ec0251125f85c6fd0e289b", + .pub_x = "e769dbbcd5ce2d83514b768d3d2d5aa0bcd8f66af15f5500", + .pub_y = "2fc6d0b039e0f28f74fbeffe9e883d4dd72296e4e95cae71", + .want = "46072acefd67bff50de355ca7a31fa6be59f26e467587259", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "a82f354cf97bee5d22dc6c079f2902ead44d96a8f614f178", + .peer_y = "a654a9aa8a1a0802f2ce0ee8a0f4ebe96dee1b37464b1ff2", + .priv = "c5a6491d78844d6617ef33be6b8bd54da221450885d5950f", + .pub_x = "db1b24f7466bc154e9d7d2c3ca52dcfe0bfc9563c5fdb6f3", + .pub_y = "1c74fbbf5bd99921f1a9a744f8e1cf770bd6a76a772b3003", + .want = "ec5580eabca9f3389d2b427ddf6e49e26d629afd03fa766e", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "3cec21b28668a12a2cf78e1a8e55d0efe065152fffc34718", + .peer_y = "1029557beba4ff1992bd21c23cb4825f6dae70e3318fd1ca", + .priv = "2ba2703c5e23f6463c5b88dc37292fabd3399b5e1fb67c05", + .pub_x = "7543148906cef9b37a71a7c08363cdd3bba50142d65241aa", + .pub_y = "8b3a6973de8dc271e27c1ead1e962fdaae3710c724daac38", + .want = "7f3929dd3cbf7673bc30d859d90b880307475f800660ea32", + }, + { + .nid = NID_X9_62_prime192v1, + .peer_x = "7082644715b8b731f8228b5118e7270d34d181f361a221fc", + .peer_y = "464649d6c88ca89614488a1cc7b8442bb42f9fb3020a3d76", + .priv = "836118c6248f882e9147976f764826c1a28755a6102977d5", + .pub_x = "fcd345a976c720caaa97de6697226825615e1287a9eff67e", + .pub_y = "58ea42edbeeafca9ff44cfd7f29abd2cbde7626d79e422c9", + .want = "72e88f3ea67d46d46dbf83926e7e2a6b85b54536741e6d2c", + }, + + { + .nid = NID_secp224r1, + .peer_x = + "af33cd0629bc7e996320a3f40368f74de8704fa37b8fab69abaae280", + .peer_y = + "882092ccbba7930f419a8a4f9bb16978bbc3838729992559a6f2e2d7", + .priv = + "8346a60fc6f293ca5a0d2af68ba71d1dd389e5e40837942df3e43cbd", + .pub_x = + "8de2e26adf72c582d6568ef638c4fd59b18da171bdf501f1d929e048", + .pub_y = + "4a68a1c2b0fb22930d120555c1ece50ea98dea8407f71be36efac0de", + .want = + "7d96f9a3bd3c05cf5cc37feb8b9d5209d5c2597464dec3e9983743e8", + }, + { + .nid = NID_secp224r1, + .peer_x = + "13bfcd4f8e9442393cab8fb46b9f0566c226b22b37076976f0617a46", + .peer_y = + "eeb2427529b288c63c2f8963c1e473df2fca6caa90d52e2f8db56dd4", + .priv = + "043cb216f4b72cdf7629d63720a54aee0c99eb32d74477dac0c2f73d", + .pub_x = + "2f90f5c8eac9c7decdbb97b6c2f715ab725e4fe40fe6d746efbf4e1b", + .pub_y = + "66897351454f927a309b269c5a6d31338be4c19a5acfc32cf656f45c", + .want = + "ee93ce06b89ff72009e858c68eb708e7bc79ee0300f73bed69bbca09", + }, + { + .nid = NID_secp224r1, + .peer_x = + "756dd806b9d9c34d899691ecb45b771af468ec004486a0fdd283411e", + .peer_y = + "4d02c2ca617bb2c5d9613f25dd72413d229fd2901513aa29504eeefb", + .priv = + "5ad0dd6dbabb4f3c2ea5fe32e561b2ca55081486df2c7c15c9622b08", + .pub_x = + "005bca45d793e7fe99a843704ed838315ab14a5f6277507e9bc37531", + .pub_y = + "43e9d421e1486ae5893bfd23c210e5c140d7c6b1ada59d842c9a98de", + .want = + "3fcc01e34d4449da2a974b23fc36f9566754259d39149790cfa1ebd3", + }, + { + .nid = NID_secp224r1, + .peer_x = + "0f537bf1c1122c55656d25e8aa8417e0b44b1526ae0523144f9921c4", + .peer_y = + "f79b26d30e491a773696cc2c79b4f0596bc5b9eebaf394d162fb8684", + .priv = + "0aa6ff55a5d820efcb4e7d10b845ea3c9f9bc5dff86106db85318e22", + .pub_x = + "2f96754131e0968198aa78fbe8c201dc5f3581c792de487340d32448", + .pub_y = + "61e8a5cd79615203b6d89e9496f9e236fe3b6be8731e743d615519c6", + .want = + "49129628b23afcef48139a3f6f59ff5e9811aa746aa4ff33c24bb940", + }, + { + .nid = NID_secp224r1, + .peer_x = + "2b3631d2b06179b3174a100f7f57131eeea8947be0786c3dc64b2239", + .peer_y = + "83de29ae3dad31adc0236c6de7f14561ca2ea083c5270c78a2e6cbc0", + .priv = + "efe6e6e25affaf54c98d002abbc6328da159405a1b752e32dc23950a", + .pub_x = + "355e962920bde043695f6bffb4b355c63da6f5de665ed46f2ec817e2", + .pub_y = + "748e095368f62e1d364edd461719793b404adbdaacbcadd88922ff37", + .want = + "fcdc69a40501d308a6839653a8f04309ec00233949522902ffa5eac6", + }, + { + .nid = NID_secp224r1, + .peer_x = + "4511403de29059f69a475c5a6a5f6cabed5d9f014436a8cb70a02338", + .peer_y = + "7d2d1b62aa046df9340f9c37a087a06b32cf7f08a223f992812a828b", + .priv = + "61cb2932524001e5e9eeed6df7d9c8935ee3322029edd7aa8acbfd51", + .pub_x = + "d50e4adabfd989d7dbc7cf4052546cc7c447a97630436997ad4b9536", + .pub_y = + "5bea503473c5eaef9552d42c40b1f2f7ca292733b255b9bbe1b12337", + .want = + "827e9025cb62e0e837c596063f3b9b5a0f7afd8d8783200086d61ec1", + }, + { + .nid = NID_secp224r1, + .peer_x = + "314a0b26dd31c248845d7cc17b61cad4608259bed85a58d1f1ffd378", + .peer_y = + "66e4b350352e119eecada382907f3619fd748ea73ae4899dfd496302", + .priv = + "8c7ace347171f92def98d845475fc82e1d1496da81ee58f505b985fa", + .pub_x = + "b1a8dcac89aca2799320b451df1c7ff4d97567abb68141c0d95fc2aa", + .pub_y = + "3524950902b1510bdc987d860afc27ad871ceaea66935abd3c0a99a8", + .want = + "335ba51228d94acbed851ca7821c801d5cb1c7975d7aa90a7159f8fa", + }, + { + .nid = NID_secp224r1, + .peer_x = + "abe6843beec2fd9e5fb64730d0be4d165438ce922ed75dd80b4603e5", + .peer_y = + "6afe8673a96c4ba9900ad85995e631e436c6cc88a2c2b47b7c4886b8", + .priv = + "382feb9b9ba10f189d99e71a89cdfe44cb554cec13a212840977fb68", + .pub_x = + "abb6f1e3773ff8fc73aea2a0b107809ce70adcefed6e41fc5cb43045", + .pub_y = + "a963897ae906c10a055eeadb97ffdd6f748d3e5621e5fff304e48ba7", + .want = + "8c2e627594206b34f7356d3426eb3d79f518ef843fbe94014cceace3", + }, + { + .nid = NID_secp224r1, + .peer_x = + "13cf9d6d2c9aae8274c27d446afd0c888ffdd52ae299a35984d4f527", + .peer_y = + "dcbee75b515751f8ee2ae355e8afd5de21c62a939a6507b538cbc4af", + .priv = + "e0d62035101ef487c485c60fb4500eebe6a32ec64dbe97dbe0232c46", + .pub_x = + "88537735e9b23e3e0e076f135a82d33f9bffb465f3abce8322a62a62", + .pub_y = + "b4c8c123673197875c0bd14ed097606d330fba2b9200ef65a44764d3", + .want = + "632abb662728dbc994508873d5c527ca5ef923c0d31fa6c47ef4c825", + }, + { + .nid = NID_secp224r1, + .peer_x = + "965b637c0dfbc0cf954035686d70f7ec30929e664e521dbaa2280659", + .peer_y = + "82a58ff61bc90019bbcbb5875d3863db0bc2a1fa34b0ad4de1a83f99", + .priv = + "b96ade5b73ba72aa8b6e4d74d7bf9c58e962ff78eb542287c7b44ba2", + .pub_x = + "37682926a54f70a4c1748f54d50d5b00138a055f924f2c65e5b0bbe4", + .pub_y = + "596afefcdd640d29635015b89bdddd1f8c2723686d332e7a06ca8799", + .want = + "34641141aab05ef58bd376d609345901fb8f63477c6be9097f037f1f", + }, + { + .nid = NID_secp224r1, + .peer_x = + "73cc645372ca2e71637cda943d8148f3382ab6dd0f2e1a49da94e134", + .peer_y = + "df5c355c23e6e232ebc3bee2ab1873ee0d83e3382f8e6fe613f6343c", + .priv = + "a40d7e12049c71e6522c7ff2384224061c3a457058b310557655b854", + .pub_x = + "399801243bfe0c2da9b0a53c8ca57f2eee87aaa94a8e4d5e029f42ca", + .pub_y = + "aa49e6d4b47cee7a5c4ab71d5a67da84e0b9b425ce3e70da68c889e7", + .want = + "4f74ac8507501a32bfc5a78d8271c200e835966e187e8d00011a8c75", + }, + { + .nid = NID_secp224r1, + .peer_x = + "546578216250354e449e21546dd11cd1c5174236739acad9ce0f4512", + .peer_y = + "d2a22fcd66d1abedc767668327c5cb9c599043276239cf3c8516af24", + .priv = + "ad2519bc724d484e02a69f05149bb047714bf0f5986fac2e222cd946", + .pub_x = + "df9c1e0ef15e53b9f626e2be1cbe893639c06f3e0439ee95d7d4b1e3", + .pub_y = + "7a52a7386adda243efdf8941085c84e31239cab92b8017336748965e", + .want = + "ad09c9ae4d2324ea81bb555b200d3c003e22a6870ee03b52df49e4de", + }, + { + .nid = NID_secp224r1, + .peer_x = + "1d46b1dc3a28123cb51346e67baec56404868678faf7d0e8b2afa22a", + .peer_y = + "0ec9e65ec97e218373e7fc115c2274d5b829a60d93f71e01d58136c3", + .priv = + "3d312a9b9d8ed09140900bbac1e095527ebc9e3c6493bcf3666e3a29", + .pub_x = + "b4a0198dc8810e884425b750928b0c960c31f7a99663400b01a179df", + .pub_y = + "812b601bfc0738242c6f86f830f27acd632ca618a0b5280c9d5769f7", + .want = + "ef029c28c68064b8abd2965a38c404fb5e944ace57e8638daba9d3cd", + }, + { + .nid = NID_secp224r1, + .peer_x = + "266d038cc7a4fe21f6c976318e827b82bb5b8f7443a55298136506e0", + .peer_y = + "df123d98a7a20bbdf3943df2e3563422f8c0cf74d53aaabdd7c973ba", + .priv = + "8ce0822dc24c153995755ac350737ef506641c7d752b4f9300c612ed", + .pub_x = + "00dfc7ec137690cd6d12fdb2fd0b8c5314582108769c2b722ffb3958", + .pub_y = + "5eef3da4ba458127346bb64023868bddb7558a2ecfc813645f4ce9fe", + .want = + "f83c16661dfcbad021cc3b5a5af51d9a18db4653866b3ff90787ce3e", + }, + { + .nid = NID_secp224r1, + .peer_x = + "eb0a09f7a1c236a61f595809ec5670efd92e4598d5e613e092cdfdca", + .peer_y = + "50787ae2f2f15b88bc10f7b5f0aee1418373f16153aebd1fba54288d", + .priv = + "0ff9b485325ab77f29e7bc379fed74bfac859482da0dee7528c19db2", + .pub_x = + "7e603e6976db83c36011508fa695d1b515249e2e54b48fcbcfb90247", + .pub_y = + "0179a600ce86adfca9b1b931fa5173d618da09e841803d19b0264286", + .want = + "f51258c63f232e55a66aa25ebd597b2018d1052c02eeb63866758005", + }, + { + .nid = NID_secp224r1, + .peer_x = + "6b2f6b18a587f562ffc61bd9b0047322286986a78f1fd139b84f7c24", + .peer_y = + "7096908e4615266be59a53cd655515056ff92370a6271a5d3823d704", + .priv = + "19cf5ff6306467f28b9fe0675a43c0582552c8c12e59ce7c38f292b1", + .pub_x = + "fc20e906e609c112cfc2e0fea6303882c5db94e87e022373ab2c082a", + .pub_y = + "aecdf1daa71782bc5a26bbbd8d7e8a76490e26abc17dffc774bd7341", + .want = + "7fdc969a186ff18429f2a276dac43beea21182d82ce2e5a0876552b1", + }, + { + .nid = NID_secp224r1, + .peer_x = + "328101ba826acd75ff9f34d5574ce0dbc92f709bad8d7a33c47940c1", + .peer_y = + "df39f1ea88488c55d5538160878b9ced18a887ea261dd712d14024ff", + .priv = + "90a15368e3532c0b1e51e55d139447c2c89bc160719d697291ea7c14", + .pub_x = + "c6837d506e976da7db3ad1267c359dff2ea6fb0b7f7f8e77024c59e9", + .pub_y = + "67eb491d2fc8a530c46525d2a8b2d7c1df5fba1ae740a4649c683ee6", + .want = + "3d60ab6db2b3ffe2d29ccff46d056e54230cf34982e241556ed2920c", + }, + { + .nid = NID_secp224r1, + .peer_x = + "0081e34270871e2ebbd94183f617b4ae15f0416dd634fe6e934cf3c0", + .peer_y = + "3a1e9f38a7b90b7317d26b9f6311063ab58b268cf489b2e50386d5d6", + .priv = + "8e0838e05e1721491067e1cabc2e8051b290e2616eec427b7121897d", + .pub_x = + "e9150f770075626019e18f95473b71e6828041791d3f08d3faeeaa2b", + .pub_y = + "475f70735eaae52308a3b763dc88efe18ab590ebafa035f6e08b001c", + .want = + "9116d72786f4db5df7a8b43078c6ab9160d423513d35ea5e2559306d", + }, + { + .nid = NID_secp224r1, + .peer_x = + "2623632fdf0bd856805a69aa186d4133ef5904e1f655a972d66cce07", + .peer_y = + "2cef9728dd06fb8b50150f529b695076d4507983912585c89bd0682e", + .priv = + "38106e93f16a381adb1d72cee3da66ae462ad4bbfea9ecdf35d0814e", + .pub_x = + "7be6c4c917829ab657dd79e8637d7aefd2f81f0de7654d957e97658d", + .pub_y = + "430d22d9e8438310f61e0d43f25fa3e34585f432baad27db3021bf0d", + .want = + "207c53dcefac789aaa0276d9200b3a940ce5f2296f4cb2e81a185d3d", + }, + { + .nid = NID_secp224r1, + .peer_x = + "8ee4d1dcc31dee4bf6fe21ca8a587721d910acfb122c16c2a77a8152", + .peer_y = + "4ebf323fff04eb477069a0ac68b345f6b1ae134efc31940e513cb99f", + .priv = + "e5d1718431cf50f6cbd1bc8019fa16762dfa12c989e5999977fb4ea2", + .pub_x = + "2ea4966e7f92ed7f5cc61fde792045f63b731d6e7d0de2577f2d8ece", + .pub_y = + "1c4a7b1ede6f839162292df424be78e8176fb6f942a3c02391700f31", + .want = + "10e467da34f48ad7072005bccd6da1b2ba3f71eafa1c393842f91d74", + }, + { + .nid = NID_secp224r1, + .peer_x = + "97dcbe6d28335882a6d193cc54a1063dd0775dc328565300bb99e691", + .peer_y = + "dad11dd5ece8cfd9f97c9a526e4a1506e6355969ee87826fc38bcd24", + .priv = + "3d635691b62a9a927c633951c9369c8862bd2119d30970c2644727d6", + .pub_x = + "438bbb980517afb20be1d674e3ac2b31cef07a9b23fb8f6e38e0d6c0", + .pub_y = + "0be5f1c47d58d21b6ed28423b32f5a94750da47edcef33ea79942afd", + .want = + "82fd2f9c60c4f999ac00bbe64bfc11da8ff8cda2e499fced65230bb1", + }, + { + .nid = NID_secp224r1, + .peer_x = + "ce9126dd53972dea1de1d11efef900de34b661859c4648c5c0e534f7", + .peer_y = + "e113b6f2c1659d07f2716e64a83c18bbce344dd2121fe85168eae085", + .priv = + "acf3c85bbdc379f02f5ea36e7f0f53095a9e7046a28685a8659bf798", + .pub_x = + "ff7511215c71d796bd646e8474be4416b91684ce0d269ef6f422013b", + .pub_y = + "b7bf5e79b5a9393bb9ea42c0bdb2d3c2dc806e1a7306aa58e4fdbea5", + .want = + "530f7e7fc932613b29c981f261cb036cba3f1df3864e0e1cba2685a2", + }, + { + .nid = NID_secp224r1, + .peer_x = + "84419967d6cfad41e75a02b6da605a97949a183a97c306c4b46e66a5", + .peer_y = + "5cc9b259718b1bc8b144fde633a894616ffd59a3a6d5d8e942c7cbb7", + .priv = + "cffd62cb00a0e3163fbf2c397fadc9618210f86b4f54a675287305f0", + .pub_x = + "04bf4d948f4430d18b4ed6c96dbaf981fa11a403ed16887f06754981", + .pub_y = + "7c1326a9cef51f79d4e78303d6064b459f612584ac2fdf593d7d5d84", + .want = + "49f6fd0139248ef4df2db05d1319bd5b1489e249827a45a8a5f12427", + }, + { + .nid = NID_secp224r1, + .peer_x = + "7c9cac35768063c2827f60a7f51388f2a8f4b7f8cd736bd6bc337477", + .peer_y = + "29ee6b849c6025d577dbcc55fbd17018f4edbc2ef105b004d6257bcd", + .priv = + "85f903e43943d13c68932e710e80de52cbc0b8f1a1418ea4da079299", + .pub_x = + "970a4a7e01d4188497ceb46955eb1b842d9085819a9b925c84529d3d", + .pub_y = + "dfa2526480f833ea0edbd204e4e365fef3472888fe7d9691c3ebc09f", + .want = + "8f7e34e597ae8093b98270a74a8dfcdbed457f42f43df487c5487161", + }, + { + .nid = NID_secp224r1, + .peer_x = + "085a7642ad8e59b1a3e8726a7547afbecffdac1dab7e57230c6a9df4", + .peer_y = + "f91c36d881fe9b8047a3530713554a1af4c25c5a8e654dcdcf689f2e", + .priv = + "cce64891a3d0129fee0d4a96cfbe7ac470b85e967529057cfa31a1d9", + .pub_x = + "a6b29632db94da2125dc1cf80e03702687b2acc1122022fa2174765a", + .pub_y = + "61723edd73e10daed73775278f1958ba56f1fc9d085ebc2b64c84fe5", + .want = + "71954e2261e8510be1a060733671d2e9d0a2d012eb4e09556d697d2a", + }, + + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "700c48f77f56584c5cc632ca65640db9" + "1b6bacce3a4df6b42ce7cc838833d287", + .peer_y = + "db71e509e3fd9b060ddb20ba5c51dcc5" + "948d46fbf640dfe0441782cab85fa4ac", + .priv = + "7d7dc5f71eb29ddaf80d6214632eeae0" + "3d9058af1fb6d22ed80badb62bc1a534", + .pub_x = + "ead218590119e8876b29146ff89ca617" + "70c4edbbf97d38ce385ed281d8a6b230", + .pub_y = + "28af61281fd35e2fa7002523acc85a42" + "9cb06ee6648325389f59edfce1405141", + .want = + "46fc62106420ff012e54a434fbdd2d25" + "ccc5852060561e68040dd7778997bd7b", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "809f04289c64348c01515eb03d5ce7ac" + "1a8cb9498f5caa50197e58d43a86a7ae", + .peer_y = + "b29d84e811197f25eba8f5194092cb6f" + "f440e26d4421011372461f579271cda3", + .priv = + "38f65d6dce47676044d58ce5139582d5" + "68f64bb16098d179dbab07741dd5caf5", + .pub_x = + "119f2f047902782ab0c9e27a54aff5eb" + "9b964829ca99c06b02ddba95b0a3f6d0", + .pub_y = + "8f52b726664cac366fc98ac7a012b268" + "2cbd962e5acb544671d41b9445704d1d", + .want = + "057d636096cb80b67a8c038c890e887d" + "1adfa4195e9b3ce241c8a778c59cda67", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "a2339c12d4a03c33546de533268b4ad6" + "67debf458b464d77443636440ee7fec3", + .peer_y = + "ef48a3ab26e20220bcda2c1851076839" + "dae88eae962869a497bf73cb66faf536", + .priv = + "1accfaf1b97712b85a6f54b148985a1b" + "dc4c9bec0bd258cad4b3d603f49f32c8", + .pub_x = + "d9f2b79c172845bfdb560bbb01447ca5" + "ecc0470a09513b6126902c6b4f8d1051", + .pub_y = + "f815ef5ec32128d3487834764678702e" + "64e164ff7315185e23aff5facd96d7bc", + .want = + "2d457b78b4614132477618a5b077965e" + "c90730a8c81a1c75d6d4ec68005d67ec", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "df3989b9fa55495719b3cf46dccd28b5" + "153f7808191dd518eff0c3cff2b705ed", + .peer_y = + "422294ff46003429d739a33206c87525" + "52c8ba54a270defc06e221e0feaf6ac4", + .priv = + "207c43a79bfee03db6f4b944f53d2fb7" + "6cc49ef1c9c4d34d51b6c65c4db6932d", + .pub_x = + "24277c33f450462dcb3d4801d57b9ced" + "05188f16c28eda873258048cd1607e0d", + .pub_y = + "c4789753e2b1f63b32ff014ec42cd6a6" + "9fac81dfe6d0d6fd4af372ae27c46f88", + .want = + "96441259534b80f6aee3d287a6bb17b5" + "094dd4277d9e294f8fe73e48bf2a0024", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "41192d2813e79561e6a1d6f53c8bc1a4" + "33a199c835e141b05a74a97b0faeb922", + .peer_y = + "1af98cc45e98a7e041b01cf35f462b75" + "62281351c8ebf3ffa02e33a0722a1328", + .priv = + "59137e38152350b195c9718d39673d51" + "9838055ad908dd4757152fd8255c09bf", + .pub_x = + "a8c5fdce8b62c5ada598f141adb3b26c" + "f254c280b2857a63d2ad783a73115f6b", + .pub_y = + "806e1aafec4af80a0d786b3de45375b5" + "17a7e5b51ffb2c356537c9e6ef227d4a", + .want = + "19d44c8d63e8e8dd12c22a87b8cd4ece" + "27acdde04dbf47f7f27537a6999a8e62", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "33e82092a0f1fb38f5649d5867fba28b" + "503172b7035574bf8e5b7100a3052792", + .peer_y = + "f2cf6b601e0a05945e335550bf648d78" + "2f46186c772c0f20d3cd0d6b8ca14b2f", + .priv = + "f5f8e0174610a661277979b58ce5c90f" + "ee6c9b3bb346a90a7196255e40b132ef", + .pub_x = + "7b861dcd2844a5a8363f6b8ef8d49364" + "0f55879217189d80326aad9480dfc149", + .pub_y = + "c4675b45eeb306405f6c33c38bc69eb2" + "bdec9b75ad5af4706aab84543b9cc63a", + .want = + "664e45d5bba4ac931cd65d52017e4be9" + "b19a515f669bea4703542a2c525cd3d3", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "6a9e0c3f916e4e315c91147be571686d" + "90464e8bf981d34a90b6353bca6eeba7", + .peer_y = + "40f9bead39c2f2bcc2602f75b8a73ec7" + "bdffcbcead159d0174c6c4d3c5357f05", + .priv = + "3b589af7db03459c23068b64f63f28d3" + "c3c6bc25b5bf76ac05f35482888b5190", + .pub_x = + "9fb38e2d58ea1baf7622e96720101cae" + "3cde4ba6c1e9fa26d9b1de0899102863", + .pub_y = + "d5561b900406edf50802dd7d73e89395" + "f8aed72fba0e1d1b61fe1d22302260f0", + .want = + "ca342daa50dc09d61be7c196c85e60a8" + "0c5cb04931746820be548cdde055679d", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "a9c0acade55c2a73ead1a86fb0a97132" + "23c82475791cd0e210b046412ce224bb", + .peer_y = + "f6de0afa20e93e078467c053d241903e" + "dad734c6b403ba758c2b5ff04c9d4229", + .priv = + "d8bf929a20ea7436b2461b541a11c80e" + "61d826c0a4c9d322b31dd54e7f58b9c8", + .pub_x = + "20f07631e4a6512a89ad487c4e9d6303" + "9e579cb0d7a556cb9e661cd59c1e7fa4", + .pub_y = + "6de91846b3eee8a5ec09c2ab1f41e21b" + "d83620ccdd1bdce3ab7ea6e02dd274f5", + .want = + "35aa9b52536a461bfde4e85fc756be92" + "8c7de97923f0416c7a3ac8f88b3d4489", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "94e94f16a98255fff2b9ac0c9598aac3" + "5487b3232d3231bd93b7db7df36f9eb9", + .peer_y = + "d8049a43579cfa90b8093a94416cbefb" + "f93386f15b3f6e190b6e3455fedfe69a", + .priv = + "0f9883ba0ef32ee75ded0d8bda39a514" + "6a29f1f2507b3bd458dbea0b2bb05b4d", + .pub_x = + "abb61b423be5d6c26e21c605832c9142" + "dc1dfe5a5fff28726737936e6fbf516d", + .pub_y = + "733d2513ef58beab202090586fac91bf" + "0fee31e80ab33473ab23a2d89e58fad6", + .want = + "605c16178a9bc875dcbff54d63fe00df" + "699c03e8a888e9e94dfbab90b25f39b4", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "e099bf2a4d557460b5544430bbf6da11" + "004d127cb5d67f64ab07c94fcdf5274f", + .peer_y = + "d9c50dbe70d714edb5e221f4e020610e" + "eb6270517e688ca64fb0e98c7ef8c1c5", + .priv = + "2beedb04b05c6988f6a67500bb813faf" + "2cae0d580c9253b6339e4a3337bb6c08", + .pub_x = + "3d63e429cb5fa895a9247129bf4e48e8" + "9f35d7b11de8158efeb3e106a2a87395", + .pub_y = + "0cae9e477ef41e7c8c1064379bb7b554" + "ddcbcae79f9814281f1e50f0403c61f3", + .want = + "f96e40a1b72840854bb62bc13c40cc27" + "95e373d4e715980b261476835a092e0b", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "f75a5fe56bda34f3c1396296626ef012" + "dc07e4825838778a645c8248cff01658", + .peer_y = + "33bbdf1b1772d8059df568b061f3f112" + "2f28a8d819167c97be448e3dc3fb0c3c", + .priv = + "77c15dcf44610e41696bab758943eff1" + "409333e4d5a11bbe72c8f6c395e9f848", + .pub_x = + "ad5d13c3db508ddcd38457e5991434a2" + "51bed49cf5ddcb59cdee73865f138c9f", + .pub_y = + "62cec1e70588aa4fdfc7b9a09daa6780" + "81c04e1208b9d662b8a2214bf8e81a21", + .want = + "8388fa79c4babdca02a8e8a34f9e4355" + "4976e420a4ad273c81b26e4228e9d3a3", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "2db4540d50230756158abf61d9835712" + "b6486c74312183ccefcaef2797b7674d", + .peer_y = + "62f57f314e3f3495dc4e099012f5e0ba" + "71770f9660a1eada54104cdfde77243e", + .priv = + "42a83b985011d12303db1a800f2610f7" + "4aa71cdf19c67d54ce6c9ed951e9093e", + .pub_x = + "ab48caa61ea35f13f8ed07ffa6a13e8d" + "b224dfecfae1a7df8b1bb6ebaf0cb97d", + .pub_y = + "1274530ca2c385a3218bddfbcbf0b402" + "4c9badd5243bff834ebff24a8618dccb", + .want = + "72877cea33ccc4715038d4bcbdfe0e43" + "f42a9e2c0c3b017fc2370f4b9acbda4a", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "cd94fc9497e8990750309e9a8534fd11" + "4b0a6e54da89c4796101897041d14ecb", + .peer_y = + "c3def4b5fe04faee0a11932229fff563" + "637bfdee0e79c6deeaf449f85401c5c4", + .priv = + "ceed35507b5c93ead5989119b9ba342c" + "fe38e6e638ba6eea343a55475de2800b", + .pub_x = + "9a8cd9bd72e71752df91440f77c54750" + "9a84df98114e7de4f26cdb39234a625d", + .pub_y = + "d07cfc84c8e144fab2839f5189bb1d7c" + "88631d579bbc58012ed9a2327da52f62", + .want = + "e4e7408d85ff0e0e9c838003f28cdbd5" + "247cdce31f32f62494b70e5f1bc36307", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "15b9e467af4d290c417402e040426fe4" + "cf236bae72baa392ed89780dfccdb471", + .peer_y = + "cdf4e9170fb904302b8fd93a820ba8cc" + "7ed4efd3a6f2d6b05b80b2ff2aee4e77", + .priv = + "43e0e9d95af4dc36483cdd1968d2b7ee" + "b8611fcce77f3a4e7d059ae43e509604", + .pub_x = + "f989cf8ee956a82e7ebd9881cdbfb2fd" + "946189b08db53559bc8cfdd48071eb14", + .pub_y = + "5eff28f1a18a616b04b7d337868679f6" + "dd84f9a7b3d7b6f8af276c19611a541d", + .want = + "ed56bcf695b734142c24ecb1fc1bb64d" + "08f175eb243a31f37b3d9bb4407f3b96", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "49c503ba6c4fa605182e186b5e81113f" + "075bc11dcfd51c932fb21e951eee2fa1", + .peer_y = + "8af706ff0922d87b3f0c5e4e31d8b259" + "aeb260a9269643ed520a13bb25da5924", + .priv = + "b2f3600df3368ef8a0bb85ab22f41fc0" + "e5f4fdd54be8167a5c3cd4b08db04903", + .pub_x = + "69c627625b36a429c398b45c38677cb3" + "5d8beb1cf78a571e40e99fe4eac1cd4e", + .pub_y = + "81690112b0a88f20f7136b28d7d47e5f" + "bc2ada3c8edd87589bc19ec9590637bd", + .want = + "bc5c7055089fc9d6c89f83c1ea1ada87" + "9d9934b2ea28fcf4e4a7e984b28ad2cf", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "19b38de39fdd2f70f7091631a4f75d19" + "93740ba9429162c2a45312401636b29c", + .peer_y = + "09aed7232b28e060941741b6828bcdfa" + "2bc49cc844f3773611504f82a390a5ae", + .priv = + "4002534307f8b62a9bf67ff641ddc60f" + "ef593b17c3341239e95bdb3e579bfdc8", + .pub_x = + "5fe964671315a18aa68a2a6e3dd1fde7" + "e23b8ce7181471cfac43c99e1ae80262", + .pub_y = + "d5827be282e62c84de531b963884ba83" + "2db5d6b2c3a256f0e604fe7e6b8a7f72", + .want = + "9a4e8e657f6b0e097f47954a63c75d74" + "fcba71a30d83651e3e5a91aa7ccd8343", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "2c91c61f33adfe9311c942fdbff6ba47" + "020feff416b7bb63cec13faf9b099954", + .peer_y = + "6cab31b06419e5221fca014fb84ec870" + "622a1b12bab5ae43682aa7ea73ea08d0", + .priv = + "4dfa12defc60319021b681b3ff84a10a" + "511958c850939ed45635934ba4979147", + .pub_x = + "c9b2b8496f1440bd4a2d1e52752fd372" + "835b364885e154a7dac49295f281ec7c", + .pub_y = + "fbe6b926a8a4de26ccc83b802b121240" + "0754be25d9f3eeaf008b09870ae76321", + .want = + "3ca1fc7ad858fb1a6aba232542f3e2a7" + "49ffc7203a2374a3f3d3267f1fc97b78", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "a28a2edf58025668f724aaf83a50956b" + "7ac1cfbbff79b08c3bf87dfd2828d767", + .peer_y = + "dfa7bfffd4c766b86abeaf5c99b6e50c" + "b9ccc9d9d00b7ffc7804b0491b67bc03", + .priv = + "1331f6d874a4ed3bc4a2c6e9c74331d3" + "039796314beee3b7152fcdba5556304e", + .pub_x = + "59e1e101521046ad9cf1d082e9d2ec7d" + "d22530cce064991f1e55c5bcf5fcb591", + .pub_y = + "482f4f673176c8fdaa0bb6e59b15a3e4" + "7454e3a04297d3863c9338d98add1f37", + .want = + "1aaabe7ee6e4a6fa732291202433a237" + "df1b49bc53866bfbe00db96a0f58224f", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "a2ef857a081f9d6eb206a81c4cf78a80" + "2bdf598ae380c8886ecd85fdc1ed7644", + .peer_y = + "563c4c20419f07bc17d0539fade1855e" + "34839515b892c0f5d26561f97fa04d1a", + .priv = + "dd5e9f70ae740073ca0204df60763fb6" + "036c45709bf4a7bb4e671412fad65da3", + .pub_x = + "30b9db2e2e977bcdc98cb87dd736cbd8" + "e78552121925cf16e1933657c2fb2314", + .pub_y = + "6a45028800b81291bce5c2e1fed7ded6" + "50620ebbe6050c6f3a7f0dfb4673ab5c", + .want = + "430e6a4fba4449d700d2733e557f66a3" + "bf3d50517c1271b1ddae1161b7ac798c", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "ccd8a2d86bc92f2e01bce4d6922cf7fe" + "1626aed044685e95e2eebd464505f01f", + .peer_y = + "e9ddd583a9635a667777d5b8a8f31b0f" + "79eba12c75023410b54b8567dddc0f38", + .priv = + "5ae026cfc060d55600717e55b8a12e11" + "6d1d0df34af831979057607c2d9c2f76", + .pub_x = + "46c9ebd1a4a3c8c0b6d572b5dcfba124" + "67603208a9cb5d2acfbb733c40cf6391", + .pub_y = + "46c913a27d044185d38b467ace011e04" + "d4d9bbbb8cb9ae25fa92aaf15a595e86", + .want = + "1ce9e6740529499f98d1f1d71329147a" + "33df1d05e4765b539b11cf615d6974d3", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "c188ffc8947f7301fb7b53e36746097c" + "2134bf9cc981ba74b4e9c4361f595e4e", + .peer_y = + "bf7d2f2056e72421ef393f0c0f2b0e00" + "130e3cac4abbcc00286168e85ec55051", + .priv = + "b601ac425d5dbf9e1735c5e2d5bdb79c" + "a98b3d5be4a2cfd6f2273f150e064d9d", + .pub_x = + "7c9e950841d26c8dde8994398b8f5d47" + "5a022bc63de7773fcf8d552e01f1ba0a", + .pub_y = + "cc42b9885c9b3bee0f8d8c57d3a8f635" + "5016c019c4062fa22cff2f209b5cc2e1", + .want = + "4690e3743c07d643f1bc183636ab2a9c" + "b936a60a802113c49bb1b3f2d0661660", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "317e1020ff53fccef18bf47bb7f2dd77" + "07fb7b7a7578e04f35b3beed222a0eb6", + .peer_y = + "09420ce5a19d77c6fe1ee587e6a49fba" + "f8f280e8df033d75403302e5a27db2ae", + .priv = + "fefb1dda1845312b5fce6b81b2be205a" + "f2f3a274f5a212f66c0d9fc33d7ae535", + .pub_x = + "38b54db85500cb20c61056edd3d88b6a" + "9dc26780a047f213a6e1b900f76596eb", + .pub_y = + "6387e4e5781571e4eb8ae62991a33b5d" + "c33301c5bc7e125d53794a39160d8fd0", + .want = + "30c2261bd0004e61feda2c16aa5e21ff" + "a8d7e7f7dbf6ec379a43b48e4b36aeb0", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "45fb02b2ceb9d7c79d9c2fa93e9c7967" + "c2fa4df5789f9640b24264b1e524fcb1", + .peer_y = + "5c6e8ecf1f7d3023893b7b1ca1e4d178" + "972ee2a230757ddc564ffe37f5c5a321", + .priv = + "334ae0c4693d23935a7e8e043ebbde21" + "e168a7cba3fa507c9be41d7681e049ce", + .pub_x = + "3f2bf1589abf3047bf3e54ac9a95379b" + "ff95f8f55405f64eca36a7eebe8ffca7", + .pub_y = + "5212a94e66c5ae9a8991872f66a72723" + "d80ec5b2e925745c456f5371943b3a06", + .want = + "2adae4a138a239dcd93c243a3803c3e4" + "cf96e37fe14e6a9b717be9599959b11c", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "a19ef7bff98ada781842fbfc51a47aff" + "39b5935a1c7d9625c8d323d511c92de6", + .peer_y = + "e9c184df75c955e02e02e400ffe45f78" + "f339e1afe6d056fb3245f4700ce606ef", + .priv = + "2c4bde40214fcc3bfc47d4cf434b629a" + "cbe9157f8fd0282540331de7942cf09d", + .pub_x = + "29c0807f10cbc42fb45c9989da50681e" + "ead716daa7b9e91fd32e062f5eb92ca0", + .pub_y = + "ff1d6d1955d7376b2da24fe1163a2716" + "59136341bc2eb1195fc706dc62e7f34d", + .want = + "2e277ec30f5ea07d6ce513149b9479b9" + "6e07f4b6913b1b5c11305c1444a1bc0b", + }, + { + .nid = NID_X9_62_prime256v1, + .peer_x = + "356c5a444c049a52fee0adeb7e5d82ae" + "5aa83030bfff31bbf8ce2096cf161c4b", + .peer_y = + "57d128de8b2a57a094d1a001e572173f" + "96e8866ae352bf29cddaf92fc85b2f92", + .priv = + "85a268f9d7772f990c36b42b0a331adc" + "92b5941de0b862d5d89a347cbf8faab0", + .pub_x = + "9cf4b98581ca1779453cc816ff28b410" + "0af56cf1bf2e5bc312d83b6b1b21d333", + .pub_y = + "7a5504fcac5231a0d12d658218284868" + "229c844a04a3450d6c7381abe080bf3b", + .want = + "1e51373bd2c6044c129c436e742a55be" + "2a668a85ae08441b6756445df5493857", + }, + + { + .nid = NID_secp384r1, + .peer_x = + "a7c76b970c3b5fe8b05d2838ae04ab47697b9eaf52e76459" + "2efda27fe7513272734466b400091adbf2d68c58e0c50066", + .peer_y = + "ac68f19f2e1cb879aed43a9969b91a0839c4c38a49749b66" + "1efedf243451915ed0905a32b060992b468c64766fc8437a", + .priv = + "3cc3122a68f0d95027ad38c067916ba0eb8c38894d22e1b1" + "5618b6818a661774ad463b205da88cf699ab4d43c9cf98a1", + .pub_x = + "9803807f2f6d2fd966cdd0290bd410c0190352fbec7ff624" + "7de1302df86f25d34fe4a97bef60cff548355c015dbb3e5f", + .pub_y = + "ba26ca69ec2f5b5d9dad20cc9da711383a9dbe34ea3fa5a2" + "af75b46502629ad54dd8b7d73a8abb06a3a3be47d650cc99", + .want = + "5f9d29dc5e31a163060356213669c8ce132e22f57c9a04f4" + "0ba7fcead493b457e5621e766c40a2e3d4d6a04b25e533f1", + }, + { + .nid = NID_secp384r1, + .peer_x = + "30f43fcf2b6b00de53f624f1543090681839717d53c7c955" + "d1d69efaf0349b7363acb447240101cbb3af6641ce4b88e0", + .peer_y = + "25e46c0c54f0162a77efcc27b6ea792002ae2ba82714299c" + "860857a68153ab62e525ec0530d81b5aa15897981e858757", + .priv = + "92860c21bde06165f8e900c687f8ef0a05d14f290b3f07d8" + "b3a8cc6404366e5d5119cd6d03fb12dc58e89f13df9cd783", + .pub_x = + "ea4018f5a307c379180bf6a62fd2ceceebeeb7d4df063a66" + "fb838aa35243419791f7e2c9d4803c9319aa0eb03c416b66", + .pub_y = + "68835a91484f05ef028284df6436fb88ffebabcdd69ab013" + "3e6735a1bcfb37203d10d340a8328a7b68770ca75878a1a6", + .want = + "a23742a2c267d7425fda94b93f93bbcc24791ac51cd8fd50" + "1a238d40812f4cbfc59aac9520d758cf789c76300c69d2ff", + }, + { + .nid = NID_secp384r1, + .peer_x = + "1aefbfa2c6c8c855a1a216774550b79a24cda37607bb1f7c" + "c906650ee4b3816d68f6a9c75da6e4242cebfb6652f65180", + .peer_y = + "419d28b723ebadb7658fcebb9ad9b7adea674f1da3dc6b63" + "97b55da0f61a3eddacb4acdb14441cb214b04a0844c02fa3", + .priv = + "12cf6a223a72352543830f3f18530d5cb37f26880a0b2944" + "82c8a8ef8afad09aa78b7dc2f2789a78c66af5d1cc553853", + .pub_x = + "fcfcea085e8cf74d0dced1620ba8423694f903a219bbf901" + "b0b59d6ac81baad316a242ba32bde85cb248119b852fab66", + .pub_y = + "972e3c68c7ab402c5836f2a16ed451a33120a7750a6039f3" + "ff15388ee622b7065f7122bf6d51aefbc29b37b03404581b", + .want = + "3d2e640f350805eed1ff43b40a72b2abed0a518bcebe8f2d" + "15b111b6773223da3c3489121db173d414b5bd5ad7153435", + }, + { + .nid = NID_secp384r1, + .peer_x = + "8bc089326ec55b9cf59b34f0eb754d93596ca290fcb3444c" + "83d4de3a5607037ec397683f8cef07eab2fe357eae36c449", + .peer_y = + "d9d16ce8ac85b3f1e94568521aae534e67139e310ec72693" + "526aa2e927b5b322c95a1a033c229cb6770c957cd3148dd7", + .priv = + "8dd48063a3a058c334b5cc7a4ce07d02e5ee6d8f1f3c51a1" + "600962cbab462690ae3cd974fb39e40b0e843daa0fd32de1", + .pub_x = + "e38c9846248123c3421861ea4d32669a7b5c3c08376ad281" + "04399494c84ff5efa3894adb2c6cbe8c3c913ef2eec5bd3c", + .pub_y = + "9fa84024a1028796df84021f7b6c9d02f0f4bd1a612a03cb" + "f75a0beea43fef8ae84b48c60172aadf09c1ad016d0bf3ce", + .want = + "6a42cfc392aba0bfd3d17b7ccf062b91fc09bbf3417612d0" + "2a90bdde62ae40c54bb2e56e167d6b70db670097eb8db854", + }, + { + .nid = NID_secp384r1, + .peer_x = + "eb952e2d9ac0c20c6cc48fb225c2ad154f53c8750b003fd3" + "b4ed8ed1dc0defac61bcdde02a2bcfee7067d75d342ed2b0", + .peer_y = + "f1828205baece82d1b267d0d7ff2f9c9e15b69a72df47058" + "a97f3891005d1fb38858f5603de840e591dfa4f6e7d489e1", + .priv = + "84ece6cc3429309bd5b23e959793ed2b111ec5cb43b6c180" + "85fcaea9efa0685d98a6262ee0d330ee250bc8a67d0e733f", + .pub_x = + "3222063a2997b302ee60ee1961108ff4c7acf1c0ef1d5fb0" + "d164b84bce71c431705cb9aea9a45f5d73806655a058bee3", + .pub_y = + "e61fa9e7fbe7cd43abf99596a3d3a039e99fa9dc93b0bdd9" + "cad81966d17eeaf557068afa7c78466bb5b22032d1100fa6", + .want = + "ce7ba454d4412729a32bb833a2d1fd2ae612d4667c3a900e" + "069214818613447df8c611de66da200db7c375cf913e4405", + }, + { + .nid = NID_secp384r1, + .peer_x = + "441d029e244eb7168d647d4df50db5f4e4974ab3fdaf022a" + "ff058b3695d0b8c814cc88da6285dc6df1ac55c553885003", + .peer_y = + "e8025ac23a41d4b1ea2aa46c50c6e479946b59b6d76497cd" + "9249977e0bfe4a6262622f13d42a3c43d66bdbb30403c345", + .priv = + "68fce2121dc3a1e37b10f1dde309f9e2e18fac47cd177095" + "1451c3484cdb77cb136d00e731260597cc2859601c01a25b", + .pub_x = + "868be0e694841830e424d913d8e7d86b84ee1021d82b0ecf" + "523f09fe89a76c0c95c49f2dfbcf829c1e39709d55efbb3b", + .pub_y = + "9195eb183675b40fd92f51f37713317e4a9b4f715c8ab22e" + "0773b1bc71d3a219f05b8116074658ee86b52e36f3897116", + .want = + "ba69f0acdf3e1ca95caaac4ecaf475bbe51b54777efce01c" + "a381f45370e486fe87f9f419b150c61e329a286d1aa265ec", + }, + { + .nid = NID_secp384r1, + .peer_x = + "3d4e6bf08a73404accc1629873468e4269e82d90d832e58a" + "d72142639b5a056ad8d35c66c60e8149fac0c797bceb7c2f", + .peer_y = + "9b0308dc7f0e6d29f8c277acbc65a21e5adb83d11e6873bc" + "0a07fda0997f482504602f59e10bc5cb476b83d0a4f75e71", + .priv = + "b1764c54897e7aae6de9e7751f2f37de849291f88f0f9109" + "3155b858d1cc32a3a87980f706b86cc83f927bdfdbeae0bd", + .pub_x = + "c371222feaa6770c6f3ea3e0dac9740def4fcf821378b7f9" + "1ff937c21e0470f70f3a31d5c6b2912195f10926942b48ae", + .pub_y = + "047d6b4d765123563f81116bc665b7b8cc6207830d805fd8" + "4da7cb805a65baa7c12fd592d1b5b5e3e65d9672a9ef7662", + .want = + "1a6688ee1d6e59865d8e3ada37781d36bb0c2717eef92e61" + "964d3927cb765c2965ea80f7f63e58c322ba0397faeaf62b", + }, + { + .nid = NID_secp384r1, + .peer_x = + "f5f6bef1d110da03be0017eac760cc34b24d092f736f237b" + "c7054b3865312a813bcb62d297fb10a4f7abf54708fe2d3d", + .peer_y = + "06fdf8d7dc032f4e10010bf19cbf6159321252ff415fb919" + "20d438f24e67e60c2eb0463204679fa356af44cea9c9ebf5", + .priv = + "f0f7a96e70d98fd5a30ad6406cf56eb5b72a510e9f192f50" + "e1f84524dbf3d2439f7287bb36f5aa912a79deaab4adea82", + .pub_x = + "99c8c41cb1ab5e0854a346e4b08a537c1706a61553387c8d" + "94943ab15196d40dbaa55b8210a77a5d00915f2c4ea69eab", + .pub_y = + "5531065bdcf17bfb3cb55a02e41a57c7f694c383ad289f90" + "0fbd656c2233a93c92e933e7a26f54cbb56f0ad875c51bb0", + .want = + "d06a568bf2336b90cbac325161be7695eacb2295f599500d" + "787f072612aca313ee5d874f807ddef6c1f023fe2b6e7cd0", + }, + { + .nid = NID_secp384r1, + .peer_x = + "7cdec77e0737ea37c67b89b7137fe38818010f4464438ee4" + "d1d35a0c488cad3fde2f37d00885d36d3b795b9f93d23a67", + .peer_y = + "28c42ee8d6027c56cf979ba4c229fdb01d234944f8ac4336" + "50112c3cf0f02844e888a3569dfef7828a8a884589aa055e", + .priv = + "9efb87ddc61d43c482ba66e1b143aef678fbd0d1bebc2000" + "941fabe677fe5b706bf78fce36d100b17cc787ead74bbca2", + .pub_x = + "4c34efee8f0c95565d2065d1bbac2a2dd25ae964320eb6bc" + "cedc5f3a9b42a881a1afca1bb6b880584fa27b01c193cd92", + .pub_y = + "d8fb01dbf7cd0a3868c26b951f393c3c56c2858cee901f77" + "93ff5d271925d13a41f8e52409f4eba1990f33acb0bac669", + .want = + "bb3b1eda9c6560d82ff5bee403339f1e80342338a9913448" + "53b56b24f109a4d94b92f654f0425edd4c205903d7586104", + }, + { + .nid = NID_secp384r1, + .peer_x = + "8eeea3a319c8df99fbc29cb55f243a720d95509515ee5cc5" + "87a5c5ae22fbbd009e626db3e911def0b99a4f7ae304b1ba", + .peer_y = + "73877dc94db9adddc0d9a4b24e8976c22d73c844370e1ee8" + "57f8d1b129a3bd5f63f40caf3bd0533e38a5f5777074ff9e", + .priv = + "d787a57fde22ec656a0a525cf3c738b30d73af61e743ea90" + "893ecb2d7b622add2f94ee25c2171467afb093f3f84d0018", + .pub_x = + "171546923b87b2cbbad664f01ce932bf09d6a61181686784" + "46bfa9f0938608cb4667a98f4ec8ac1462285c2508f74862", + .pub_y = + "fa41cb4db68ae71f1f8a3e8939dc52c2dec61a83c983beb2" + "a02baf29ec49278088882ed0cf56c74b5c173b552ccf63cf", + .want = + "1e97b60add7cb35c7403dd884c0a75795b7683fff8b49f9d" + "8672a8206bfdcf0a106b8768f983258c74167422e44e4d14", + }, + { + .nid = NID_secp384r1, + .peer_x = + "a721f6a2d4527411834b13d4d3a33c29beb83ab7682465c6" + "cbaf6624aca6ea58c30eb0f29dd842886695400d7254f20f", + .peer_y = + "14ba6e26355109ad35129366d5e3a640ae798505a7fa55a9" + "6a36b5dad33de00474f6670f522214dd7952140ab0a7eb68", + .priv = + "83d70f7b164d9f4c227c767046b20eb34dfc778f5387e32e" + "834b1e6daec20edb8ca5bb4192093f543b68e6aeb7ce788b", + .pub_x = + "57cd770f3bbcbe0c78c770eab0b169bc45e139f86378ffae" + "1c2b16966727c2f2eb724572b8f3eb228d130db4ff862c63", + .pub_y = + "7ec5c8813b685558d83e924f14bc719f6eb7ae0cbb2c4742" + "27c5bda88637a4f26c64817929af999592da6f787490332f", + .want = + "1023478840e54775bfc69293a3cf97f5bc914726455c6653" + "8eb5623e218feef7df4befa23e09d77145ad577db32b41f9", + }, + { + .nid = NID_secp384r1, + .peer_x = + "d882a8505c2d5cb9b8851fc676677bb0087681ad53faceba" + "1738286b45827561e7da37b880276c656cfc38b32ade847e", + .peer_y = + "34b314bdc134575654573cffaf40445da2e6aaf987f7e913" + "cd4c3091523058984a25d8f21da8326192456c6a0fa5f60c", + .priv = + "8f558e05818b88ed383d5fca962e53413db1a0e4637eda19" + "4f761944cbea114ab9d5da175a7d57882550b0e432f395a9", + .pub_x = + "9a2f57f4867ce753d72b0d95195df6f96c1fae934f602efd" + "7b6a54582f556cfa539d89005ca2edac08ad9b72dd1f60ba", + .pub_y = + "d9b94ee82da9cc601f346044998ba387aee56404dc6ecc8a" + "b2b590443319d0b2b6176f9d0eac2d44678ed561607d09a9", + .want = + "6ad6b9dc8a6cf0d3691c501cbb967867f6e4bbb764b60dbf" + "f8fcff3ed42dbba39d63cf325b4b4078858495ddee75f954", + }, + { + .nid = NID_secp384r1, + .peer_x = + "815c9d773dbf5fb6a1b86799966247f4006a23c92e68c55e" + "9eaa998b17d8832dd4d84d927d831d4f68dac67c6488219f", + .peer_y = + "e79269948b2611484560fd490feec887cb55ef99a4b52488" + "0fa7499d6a07283aae2afa33feab97deca40bc606c4d8764", + .priv = + "0f5dee0affa7bbf239d5dff32987ebb7cf84fcceed643e1d" + "3c62d0b3352aec23b6e5ac7fa4105c8cb26126ad2d1892cb", + .pub_x = + "23346bdfbc9d7c7c736e02bdf607671ff6082fdd27334a8b" + "c75f3b23681ebe614d0597dd614fae58677c835a9f0b273b", + .pub_y = + "82ba36290d2f94db41479eb45ab4eaf67928a2315138d59e" + "ecc9b5285dfddd6714f77557216ea44cc6fc119d8243efaf", + .want = + "cc9e063566d46b357b3fcae21827377331e5e290a36e60cd" + "7c39102b828ae0b918dc5a02216b07fe6f1958d834e42437", + }, + { + .nid = NID_secp384r1, + .peer_x = + "1c0eeda7a2be000c5bdcda0478aed4db733d2a9e34122437" + "9123ad847030f29e3b168fa18e89a3c0fba2a6ce1c28fc3b", + .peer_y = + "ec8c1c83c118c4dbea94271869f2d868eb65e8b44e21e6f1" + "4b0f4d9b38c068daefa27114255b9a41d084cc4a1ad85456", + .priv = + "037b633b5b8ba857c0fc85656868232e2febf59578718391" + "b81da8541a00bfe53c30ae04151847f27499f8d7abad8cf4", + .pub_x = + "8878ac8a947f7d5cb2b47aad24fbb8210d86126585399a28" + "71f84aa9c5fde3074ae540c6bf82275ca822d0feb862bc74", + .pub_y = + "632f5cd2f900c2711c32f8930728eb647d31edd8d650f965" + "4e7d33e5ed1b475489d08daa30d8cbcba6bfc3b60d9b5a37", + .want = + "deff7f03bd09865baf945e73edff6d5122c03fb561db87de" + "c8662e09bed4340b28a9efe118337bb7d3d4f7f568635ff9", + }, + { + .nid = NID_secp384r1, + .peer_x = + "c95c185e256bf997f30b311548ae7f768a38dee43eeeef43" + "083f3077be70e2bf39ac1d4daf360c514c8c6be623443d1a", + .peer_y = + "3e63a663eaf75d8a765ab2b9a35513d7933fa5e26420a524" + "4550ec6c3b6f033b96db2aca3d6ac6aab052ce929595aea5", + .priv = + "e3d07106bedcc096e7d91630ffd3094df2c7859db8d7edbb" + "2e37b4ac47f429a637d06a67d2fba33838764ef203464991", + .pub_x = + "e74a1a2b85f1cbf8dbbdf050cf1aff8acb02fda2fb6591f9" + "d3cfe4e79d0ae938a9c1483e7b75f8db24505d65065cdb18", + .pub_y = + "1773ee591822f7abaa856a1a60bc0a5203548dbd1cb50254" + "66eff8481bd07614eaa04a16c3db76905913e972a5b6b59d", + .want = + "c8b1038f735ad3bb3e4637c3e47eab487637911a6b7950a4" + "e461948329d3923b969e5db663675623611a457fcda35a71", + }, + { + .nid = NID_secp384r1, + .peer_x = + "3497238a7e6ad166df2dac039aa4dac8d17aa925e7c7631e" + "b3b56e3aaa1c545fcd54d2e5985807910fb202b1fc191d2a", + .peer_y = + "a49e5c487dcc7aa40a8f234c979446040d9174e3ad357d40" + "4d7765183195aed3f913641b90c81a306ebf0d8913861316", + .priv = + "f3f9b0c65a49a506632c8a45b10f66b5316f9eeb06fae218" + "f2da62333f99905117b141c760e8974efc4af10570635791", + .pub_x = + "a4ad77aa7d86e5361118a6b921710c820721210712f4c347" + "985fdee58aa4effa1e28be80a17b120b139f96300f89b49b", + .pub_y = + "1ddf22e07e03f1560d8f45a480094560dba9fae7f9531130" + "c1b57ebb95982496524f31d3797793396fa823f22bdb4328", + .want = + "d337eaa32b9f716b8747b005b97a553c59dab0c51df41a2d" + "49039cdae705aa75c7b9e7bc0b6a0e8c578c902bc4fff23e", + }, + { + .nid = NID_secp384r1, + .peer_x = + "90a34737d45b1aa65f74e0bd0659bc118f8e4b774b761944" + "ffa6573c6df4f41dec0d11b697abd934d390871d4b453240", + .peer_y = + "9b590719bb3307c149a7817be355d684893a307764b512ee" + "ffe07cb699edb5a6ffbf8d6032e6c79d5e93e94212c2aa4e", + .priv = + "59fce7fad7de28bac0230690c95710c720e528f9a4e54d3a" + "6a8cd5fc5c5f21637031ce1c5b4e3d39647d8dcb9b794664", + .pub_x = + "9c43bf971edf09402876ee742095381f78b1bd3aa39b5132" + "af75dbfe7e98bd78bde10fe2e903c2b6379e1deee175a1b0", + .pub_y = + "a6c58ecea5a477bb01bd543b339f1cc49f1371a2cda4d46e" + "b4e53e250597942351a99665a122ffea9bde0636c375daf2", + .want = + "32d292b695a4488e42a7b7922e1ae537d76a3d21a0b2e368" + "75f60e9f6d3e8779c2afb3a413b9dd79ae18e70b47d337c1", + }, + { + .nid = NID_secp384r1, + .peer_x = + "dda546acfc8f903d11e2e3920669636d44b2068aeb66ff07" + "aa266f0030e1535b0ed0203cb8a460ac990f1394faf22f1d", + .peer_y = + "15bbb2597913035faadf413476f4c70f7279769a40c986f4" + "70c427b4ee4962abdf8173bbad81874772925fd32f0b159f", + .priv = + "3e49fbf950a424c5d80228dc4bc35e9f6c6c0c1d04440998" + "da0a609a877575dbe437d6a5cedaa2ddd2a1a17fd112aded", + .pub_x = + "5a949594228b1a3d6f599eb3db0d06070fbc551c657b5823" + "4ba164ce3fe415fa5f3eb823c08dc29b8c341219c77b6b3d", + .pub_y = + "2baad447c8c290cfed25edd9031c41d0b76921457327f42d" + "b31122b81f337bbf0b1039ec830ce9061a3761953c75e4a8", + .want = + "1220e7e6cad7b25df98e5bbdcc6c0b65ca6c2a50c5ff6c41" + "dca71e475646fd489615979ca92fb4389aeadefde79a24f1", + }, + { + .nid = NID_secp384r1, + .peer_x = + "788be2336c52f4454d63ee944b1e49bfb619a08371048e6d" + "a92e584eae70bde1f171c4df378bd1f3c0ab03048a237802", + .peer_y = + "4673ebd8db604eaf41711748bab2968a23ca4476ce144e72" + "8247f08af752929157b5830f1e26067466bdfa8b65145a33", + .priv = + "50ccc1f7076e92f4638e85f2db98e0b483e6e2204c92bdd4" + "40a6deea04e37a07c6e72791c190ad4e4e86e01efba84269", + .pub_x = + "756c07df0ce32c839dac9fb4733c9c28b70113a676a7057c" + "38d223f22a3a9095a8d564653af528e04c7e1824be4a6512", + .pub_y = + "17c2ce6962cbd2a2e066297b39d57dd9bb4680f0191d390f" + "70b4e461419b2972ce68ad46127fdda6c39195774ea86df3", + .want = + "793bb9cd22a93cf468faf804a38d12b78cb12189ec679ddd" + "2e9aa21fa9a5a0b049ab16a23574fe04c1c3c02343b91beb", + }, + { + .nid = NID_secp384r1, + .peer_x = + "d09bb822eb99e38060954747c82bb3278cf96bbf36fece34" + "00f4c873838a40c135eb3babb9293bd1001bf3ecdee7bf26", + .peer_y = + "d416db6e1b87bbb7427788a3b6c7a7ab2c165b1e366f9608" + "df512037584f213a648d47f16ac326e19aae972f63fd76c9", + .priv = + "06f132b71f74d87bf99857e1e4350a594e5fe35533b88855" + "2ceccbc0d8923c902e36141d7691e28631b8bc9bafe5e064", + .pub_x = + "2a3cc6b8ff5cde926e7e3a189a1bd029c9b586351af8838f" + "4f201cb8f4b70ef3b0da06d352c80fc26baf8f42b784459e", + .pub_y = + "bf9985960176da6d23c7452a2954ffcbbcb24249b43019a2" + "a023e0b3dabd461f19ad3e775c364f3f11ad49f3099400d3", + .want = + "012d191cf7404a523678c6fc075de8285b243720a9030477" + "08bb33e501e0dbee5bcc40d7c3ef6c6da39ea24d830da1e8", + }, + { + .nid = NID_secp384r1, + .peer_x = + "13741262ede5861dad71063dfd204b91ea1d3b7c631df68e" + "b949969527d79a1dc59295ef7d2bca6743e8cd77b04d1b58", + .peer_y = + "0baaeadc7e19d74a8a04451a135f1be1b02fe299f9dc00bf" + "df201e83d995c6950bcc1cb89d6f7b30bf54656b9a4da586", + .priv = + "12048ebb4331ec19a1e23f1a2c773b664ccfe90a28bfb846" + "fc12f81dff44b7443c77647164bf1e9e67fd2c07a6766241", + .pub_x = + "bc18836bc7a9fdf54b5352f37d7528ab8fa8ec544a8c6180" + "511cbfdd49cce377c39e34c031b5240dc9980503ed2f262c", + .pub_y = + "8086cbe338191080f0b7a16c7afc4c7b0326f9ac66f58552" + "ef4bb9d24de3429ed5d3277ed58fcf48f2b5f61326bec6c6", + .want = + "ad0fd3ddffe8884b9263f3c15fe1f07f2a5a22ffdc7e9670" + "85eea45f0cd959f20f18f522763e28bcc925e496a52dda98", + }, + { + .nid = NID_secp384r1, + .peer_x = + "9e22cbc18657f516a864b37b783348b66f1aa9626cd631f4" + "fa1bd32ad88cf11db52057c660860d39d11fbf024fabd444", + .peer_y = + "6b0d53c79681c28116df71e9cee74fd56c8b7f04b39f1198" + "cc72284e98be9562e35926fb4f48a9fbecafe729309e8b6f", + .priv = + "34d61a699ca576169fcdc0cc7e44e4e1221db0fe63d16850" + "c8104029f7d48449714b9884328cae189978754ab460b486", + .pub_x = + "867f81104ccd6b163a7902b670ef406042cb0cce7dcdc63d" + "1dfc91b2c40e3cdf7595834bf9eceb79849f1636fc8462fc", + .pub_y = + "9d4bde8e875ec49697d258d1d59465f8431c6f5531e1c59e" + "9f9ebe3cf164a8d9ce10a12f1979283a959bad244dd83863", + .want = + "dc4ca392dc15e20185f2c6a8ea5ec31dfc96f56153a47394" + "b3072b13d0015f5d4ae13beb3bed54d65848f9b8383e6c95", + }, + { + .nid = NID_secp384r1, + .peer_x = + "2db5da5f940eaa884f4db5ec2139b0469f38e4e6fbbcc52d" + "f15c0f7cf7fcb1808c749764b6be85d2fdc5b16f58ad5dc0", + .peer_y = + "22e8b02dcf33e1b5a083849545f84ad5e43f77cb71546dbb" + "ac0d11bdb2ee202e9d3872e8d028c08990746c5e1dde9989", + .priv = + "dc60fa8736d702135ff16aab992bb88eac397f5972456c72" + "ec447374d0d8ce61153831bfc86ad5a6eb5b60bfb96a862c", + .pub_x = + "b69beede85d0f829fec1b893ccb9c3e052ff692e13b97453" + "7bc5b0f9feaf7b22e84f03231629b24866bdb4b8cf908914", + .pub_y = + "66f85e2bfcaba2843285b0e14ebc07ef7dafff8b424416fe" + "e647b59897b619f20eed95a632e6a4206bf7da429c04c560", + .want = + "d765b208112d2b9ed5ad10c4046e2e3b0dbf57c469329519" + "e239ac28b25c7d852bf757d5de0ee271cadd021d86cfd347", + }, + { + .nid = NID_secp384r1, + .peer_x = + "329647baa354224eb4414829c5368c82d7893b39804e08cb" + "b2180f459befc4b347a389a70c91a23bd9d30c83be5295d3", + .peer_y = + "cc8f61923fad2aa8e505d6cfa126b9fabd5af9dce290b756" + "60ef06d1caa73681d06089c33bc4246b3aa30dbcd2435b12", + .priv = + "6fa6a1c704730987aa634b0516a826aba8c6d6411d3a4c89" + "772d7a62610256a2e2f289f5c3440b0ec1e70fa339e251ce", + .pub_x = + "53de1fc1328e8de14aecab29ad8a40d6b13768f86f7d2984" + "33d20fec791f86f8bc73f358098b256a298bb488de257bf4", + .pub_y = + "ac28944fd27f17b82946c04c66c41f0053d3692f275da55c" + "d8739a95bd8cd3af2f96e4de959ea8344d8945375905858b", + .want = + "d3778850aeb58804fbe9dfe6f38b9fa8e20c2ca4e0dec335" + "aafceca0333e3f2490b53c0c1a14a831ba37c4b9d74be0f2", + }, + { + .nid = NID_secp384r1, + .peer_x = + "29d8a36d22200a75b7aea1bb47cdfcb1b7fd66de96704143" + "4728ab5d533a060df732130600fe6f75852a871fb2938e39", + .peer_y = + "e19b53db528395de897a45108967715eb8cb55c3fcbf2337" + "9372c0873a058d57544b102ecce722b2ccabb1a603774fd5", + .priv = + "74ad8386c1cb2ca0fcdeb31e0869bb3f48c036afe2ef110c" + "a302bc8b910f621c9fcc54cec32bb89ec7caa84c7b8e54a8", + .pub_x = + "27a3e83cfb9d5122e73129d801615857da7cc089cccc9c54" + "ab3032a19e0a0a9f677346e37f08a0b3ed8da6e5dd691063", + .pub_y = + "8d60e44aa5e0fd30c918456796af37f0e41957901645e5c5" + "96c6d989f5859b03a0bd7d1f4e77936fff3c74d204e5388e", + .want = + "81e1e71575bb4505498de097350186430a6242fa6c57b85a" + "5f984a23371123d2d1424eefbf804258392bc723e4ef1e35", + }, + + { + .nid = NID_secp521r1, + .peer_x = + "000000685a48e86c79f0f0875f7bc18d25eb5fc8c0b07e5d" + "a4f4370f3a9490340854334b1e1b87fa395464c60626124a" + "4e70d0f785601d37c09870ebf176666877a2046d", + .peer_y = + "000001ba52c56fc8776d9e8f5db4f0cc27636d0b741bbe05" + "400697942e80b739884a83bde99e0f6716939e632bc8986f" + "a18dccd443a348b6c3e522497955a4f3c302f676", + .priv = + "0000017eecc07ab4b329068fba65e56a1f8890aa935e5713" + "4ae0ffcce802735151f4eac6564f6ee9974c5e6887a1fefe" + "e5743ae2241bfeb95d5ce31ddcb6f9edb4d6fc47", + .pub_x = + "000000602f9d0cf9e526b29e22381c203c48a886c2b06730" + "33366314f1ffbcba240ba42f4ef38a76174635f91e6b4ed3" + "4275eb01c8467d05ca80315bf1a7bbd945f550a5", + .pub_y = + "000001b7c85f26f5d4b2d7355cf6b02117659943762b6d1d" + "b5ab4f1dbc44ce7b2946eb6c7de342962893fd387d1b73d7" + "a8672d1f236961170b7eb3579953ee5cdc88cd2d", + .want = + "005fc70477c3e63bc3954bd0df3ea0d1f41ee21746ed95fc" + "5e1fdf90930d5e136672d72cc770742d1711c3c3a4c334a0" + "ad9759436a4d3c5bf6e74b9578fac148c831", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000001df277c152108349bc34d539ee0cf06b24f5d350067" + "7b4445453ccc21409453aafb8a72a0be9ebe54d12270aa51" + "b3ab7f316aa5e74a951c5e53f74cd95fc29aee7a", + .peer_y = + "0000013d52f33a9f3c14384d1587fa8abe7aed74bc33749a" + "d9c570b471776422c7d4505d9b0a96b3bfac041e4c6a6990" + "ae7f700e5b4a6640229112deafa0cd8bb0d089b0", + .priv = + "000000816f19c1fb10ef94d4a1d81c156ec3d1de08b66761" + "f03f06ee4bb9dcebbbfe1eaa1ed49a6a990838d8ed318c14" + "d74cc872f95d05d07ad50f621ceb620cd905cfb8", + .pub_x = + "000000d45615ed5d37fde699610a62cd43ba76bedd8f85ed" + "31005fe00d6450fbbd101291abd96d4945a8b57bc73b3fe9" + "f4671105309ec9b6879d0551d930dac8ba45d255", + .pub_y = + "000001425332844e592b440c0027972ad1526431c06732df" + "19cd46a242172d4dd67c2c8c99dfc22e49949a56cf90c647" + "3635ce82f25b33682fb19bc33bd910ed8ce3a7fa", + .want = + "000b3920ac830ade812c8f96805da2236e002acbbf13596a" + "9ab254d44d0e91b6255ebf1229f366fb5a05c5884ef46032" + "c26d42189273ca4efa4c3db6bd12a6853759", + }, + { + .nid = NID_secp521r1, + .peer_x = + "00000092db3142564d27a5f0006f819908fba1b85038a5bc" + "2509906a497daac67fd7aee0fc2daba4e4334eeaef0e0019" + "204b471cd88024f82115d8149cc0cf4f7ce1a4d5", + .peer_y = + "0000016bad0623f517b158d9881841d2571efbad63f85cbe" + "2e581960c5d670601a6760272675a548996217e4ab2b8ebc" + "e31d71fca63fcc3c08e91c1d8edd91cf6fe845f8", + .priv = + "0000012f2e0c6d9e9d117ceb9723bced02eb3d4eebf5feea" + "f8ee0113ccd8057b13ddd416e0b74280c2d0ba8ed291c443" + "bc1b141caf8afb3a71f97f57c225c03e1e4d42b0", + .pub_x = + "000000717fcb3d4a40d103871ede044dc803db508aaa4ae7" + "4b70b9fb8d8dfd84bfecfad17871879698c292d2fd5e17b4" + "f9343636c531a4fac68a35a93665546b9a878679", + .pub_y = + "000000f3d96a8637036993ab5d244500fff9d2772112826f" + "6436603d3eb234a44d5c4e5c577234679c4f9df725ee5b91" + "18f23d8a58d0cc01096daf70e8dfec0128bdc2e8", + .want = + "006b380a6e95679277cfee4e8353bf96ef2a1ebdd060749f" + "2f046fe571053740bbcc9a0b55790bc9ab56c3208aa05ddf" + "746a10a3ad694daae00d980d944aabc6a08f", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000000fdd40d9e9d974027cb3bae682162eac1328ad61bc4" + "353c45bf5afe76bf607d2894c8cce23695d920f2464fda47" + "73d4693be4b3773584691bdb0329b7f4c86cc299", + .peer_y = + "00000034ceac6a3fef1c3e1c494bfe8d872b183832219a7e" + "14da414d4e3474573671ec19b033be831b915435905925b4" + "4947c592959945b4eb7c951c3b9c8cf52530ba23", + .priv = + "000000e548a79d8b05f923b9825d11b656f222e8cb98b0f8" + "9de1d317184dc5a698f7c71161ee7dc11cd31f4f4f8ae3a9" + "81e1a3e78bdebb97d7c204b9261b4ef92e0918e0", + .pub_x = + "0000000ce800217ed243dd10a79ad73df578aa8a3f9194af" + "528cd1094bbfee27a3b5481ad5862c8876c0c3f91294c0ab" + "3aa806d9020cbaa2ed72b7fecdc5a09a6dad6f32", + .pub_y = + "000001543c9ab45b12469232918e21d5a351f9a4b9cbf9ef" + "b2afcc402fa9b31650bec2d641a05c440d35331c0893d11f" + "b13151335988b303341301a73dc5f61d574e67d9", + .want = + "00fbbcd0b8d05331fef6086f22a6cce4d35724ab7a2f49dd" + "8458d0bfd57a0b8b70f246c17c4468c076874b0dff7a0336" + "823b19e98bf1cec05e4beffb0591f97713c6", + }, + { + .nid = NID_secp521r1, + .peer_x = + "00000098d99dee0816550e84dbfced7e88137fddcf581a72" + "5a455021115fe49f8dc3cf233cd9ea0e6f039dc7919da973" + "cdceaca205da39e0bd98c8062536c47f258f44b5", + .peer_y = + "000000cd225c8797371be0c4297d2b457740100c774141d8" + "f214c23b61aa2b6cd4806b9b70722aa4965fb622f42b7391" + "e27e5ec21c5679c5b06b59127372997d421adc1e", + .priv = + "000001c8aae94bb10b8ca4f7be577b4fb32bb2381032c494" + "2c24fc2d753e7cc5e47b483389d9f3b956d20ee9001b1eef" + "9f23545f72c5602140046839e963313c3decc864", + .pub_x = + "00000106a14e2ee8ff970aa8ab0c79b97a33bba2958e070b" + "75b94736b77bbe3f777324fa52872771aa88a63a9e8490c3" + "378df4dc760cd14d62be700779dd1a4377943656", + .pub_y = + "0000002366ce3941e0b284b1aa81215d0d3b9778fce23c8c" + "d1e4ed6fa0abf62156c91d4b3eb55999c3471bed275e9e60" + "e5aa9d690d310bfb15c9c5bbd6f5e9eb39682b74", + .want = + "0145cfa38f25943516c96a5fd4bfebb2f645d10520117aa5" + "1971eff442808a23b4e23c187e639ff928c3725fbd1c0c2a" + "d0d4aeb207bc1a6fb6cb6d467888dc044b3c", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000007ae115adaaf041691ab6b7fb8c921f99d8ed32d283" + "d67084e80b9ad9c40c56cd98389fb0a849d9ecf7268c297b" + "6f93406119f40e32b5773ed25a28a9a85c4a7588", + .peer_y = + "000001a28e004e37eeaefe1f4dbb71f1878696141af3a10a" + "9691c4ed93487214643b761fa4b0fbeeb247cf6d3fba7a60" + "697536ad03f49b80a9d1cb079673654977c5fa94", + .priv = + "0000009b0af137c9696c75b7e6df7b73156bb2d45f482e5a" + "4217324f478b10ceb76af09724cf86afa316e7f89918d31d" + "54824a5c33107a483c15c15b96edc661340b1c0e", + .pub_x = + "000000748cdbb875d35f4bccb62abe20e82d32e4c14dc2fe" + "b5b87da2d0ccb11c9b6d4b7737b6c46f0dfb4d896e2db92f" + "cf53cdbbae2a404c0babd564ad7adeac6273efa3", + .pub_y = + "000001984acab8d8f173323de0bb60274b228871609373bb" + "22a17287e9dec7495873abc09a8915b54c8455c8e02f654f" + "602e23a2bbd7a9ebb74f3009bd65ecc650814cc0", + .want = + "005c5721e96c273319fd60ecc46b5962f698e974b429f28f" + "e6962f4ac656be2eb8674c4aafc037eab48ece612953b1e8" + "d861016b6ad0c79805784c67f73ada96f351", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000012588115e6f7f7bdcfdf57f03b169b479758baafdaf" + "569d04135987b2ce6164c02a57685eb5276b5dae6295d3fe" + "90620f38b5535c6d2260c173e61eb888ca920203", + .peer_y = + "000001542c169cf97c2596fe2ddd848a222e367c5f7e6267" + "ebc1bcd9ab5dcf49158f1a48e4af29a897b7e6a82091c2db" + "874d8e7abf0f58064691344154f396dbaed188b6", + .priv = + "000001e48faacee6dec83ffcde944cf6bdf4ce4bae727478" + "88ebafee455b1e91584971efb49127976a52f4142952f7c2" + "07ec0265f2b718cf3ead96ea4f62c752e4f7acd3", + .pub_x = + "0000010eb1b4d9172bcc23f4f20cc9560fc54928c3f34ea6" + "1c00391dc766c76ed9fa608449377d1e4fadd12360254173" + "30b4b91086704ace3e4e6484c606e2a943478c86", + .pub_y = + "00000149413864069825ee1d0828da9f4a97713005e9bd1a" + "dbc3b38c5b946900721a960fe96ad2c1b3a44fe3de915613" + "6d44cb17cbc2415729bb782e16bfe2deb3069e43", + .want = + "01736d9717429b4f412e903febe2f9e0fffd81355d6ce2c0" + "6ff3f66a3be15ceec6e65e308347593f00d7f33591da4043" + "c30763d72749f72cdceebe825e4b34ecd570", + }, + { + .nid = NID_secp521r1, + .peer_x = + "00000169491d55bd09049fdf4c2a53a660480fee4c03a053" + "8675d1cd09b5bba78dac48543ef118a1173b3fbf8b20e39c" + "e0e6b890a163c50f9645b3d21d1cbb3b60a6fff4", + .peer_y = + "00000083494b2eba76910fed33c761804515011fab50e3b3" + "77abd8a8a045d886d2238d2c268ac1b6ec88bd71b7ba78e2" + "c33c152e4bf7da5d565e4acbecf5e92c7ad662bb", + .priv = + "000000c29aa223ea8d64b4a1eda27f39d3bc98ea0148dd98" + "c1cbe595f8fd2bfbde119c9e017a50f5d1fc121c08c1cef3" + "1b758859556eb3e0e042d8dd6aaac57a05ca61e3", + .pub_x = + "0000001511c848ef60d5419a98d10204db0fe58224124370" + "061bcfa4e9249d50618c56bf3722471b259f38263bb7b280" + "d23caf2a1ee8737f9371cdb2732cdc958369930c", + .pub_y = + "000001d461681ae6d8c49b4c5f4d6016143fb1bd7491573e" + "3ed0e6c48b82e821644f87f82f0e5f08fd16f1f98fa17586" + "200ab02ed8c627b35c3f27617ec5fd92f456203f", + .want = + "018f2ae9476c771726a77780208dedfefa205488996b18fe" + "cc50bfd4c132753f5766b2cd744afa9918606de2e016effc" + "63622e9029e76dc6e3f0c69f7aeced565c2c", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000008415f5bbd0eee387d6c09d0ef8acaf29c66db45d6b" + "a101860ae45d3c60e1e0e3f7247a4626a60fdd404965c356" + "6c79f6449e856ce0bf94619f97da8da24bd2cfb6", + .peer_y = + "000000fdd7c59c58c361bc50a7a5d0d36f723b17c4f2ad2b" + "03c24d42dc50f74a8c465a0afc4683f10fab84652dfe9e92" + "8c2626b5456453e1573ff60be1507467d431fbb2", + .priv = + "00000028692be2bf5c4b48939846fb3d5bce74654bb2646e" + "15f8389e23708a1afadf561511ea0d9957d0b53453819d60" + "fba8f65a18f7b29df021b1bb01cd163293acc3cc", + .pub_x = + "000001cfdc10c799f5c79cb6930a65fba351748e07567993" + "e5e410ef4cacc4cd8a25784991eb4674e41050f930c7190a" + "c812b9245f48a7973b658daf408822fe5b85f668", + .pub_y = + "00000180d9ddfc9af77b9c4a6f02a834db15e535e0b3845b" + "2cce30388301b51cecbe3276307ef439b5c9e6a72dc2d94d" + "879bc395052dbb4a5787d06efb280210fb8be037", + .want = + "0105a346988b92ed8c7a25ce4d79d21bc86cfcc7f99c6cd1" + "9dbb4a39f48ab943b79e4f0647348da0b80bd864b85c6b8d" + "92536d6aa544dc7537a00c858f8b66319e25", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000001c721eea805a5cba29f34ba5758775be0cf6160e6c0" + "8723f5ab17bf96a1ff2bd9427961a4f34b07fc0b14ca4b2b" + "f6845debd5a869f124ebfa7aa72fe565050b7f18", + .peer_y = + "000000b6e89eb0e1dcf181236f7c548fd1a8c16b258b52c1" + "a9bfd3fe8f22841b26763265f074c4ccf2d634ae97b70195" + "6f67a11006c52d97197d92f585f5748bc2672eeb", + .priv = + "000001194d1ee613f5366cbc44b504d21a0cf6715e209cd3" + "58f2dd5f3e71cc0d67d0e964168c42a084ebda746f9863a8" + "6bacffc819f1edf1b8c727ccfb3047240a57c435", + .pub_x = + "0000016bd15c8a58d366f7f2b2f298cc87b7485e9ee70d11" + "d12448b8377c0a82c7626f67aff7f97be7a3546bf417eeed" + "df75a93c130191c84108042ea2fca17fd3f80d14", + .pub_y = + "000001560502d04b74fce1743aab477a9d1eac93e5226981" + "fdb97a7478ce4ce566ff7243931284fad850b0c2bcae0ddd" + "2d97790160c1a2e77c3ed6c95ecc44b89e2637fc", + .want = + "004531b3d2c6cd12f21604c8610e6723dbf4daf80b5a459d" + "6ba5814397d1c1f7a21d7c114be964e27376aaebe3a7bc3d" + "6af7a7f8c7befb611afe487ff032921f750f", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000001c35823e440a9363ab98d9fc7a7bc0c0532dc7977a7" + "9165599bf1a9cc64c00fb387b42cca365286e8430360bfad" + "3643bc31354eda50dc936c329ecdb60905c40fcb", + .peer_y = + "000000d9e7f433531e44df4f6d514201cbaabb06badd6783" + "e01111726d815531d233c5cdb722893ffbb2027259d594de" + "77438809738120c6f783934f926c3fb69b40c409", + .priv = + "000001fd90e3e416e98aa3f2b6afa7f3bf368e451ad9ca5b" + "d54b5b14aee2ed6723dde5181f5085b68169b09fbec72137" + "2ccf6b284713f9a6356b8d560a8ff78ca3737c88", + .pub_x = + "000001ebea1b10d3e3b971b7efb69fc878de11c7f472e4e4" + "d384c31b8d6288d8071517acade9b39796c7af5163bcf71a" + "eda777533f382c6cf0a4d9bbb938c85f44b78037", + .pub_y = + "0000016b0e3e19c2996b2cbd1ff64730e7ca90edca1984f9" + "b2951333535e5748baa34a99f61ff4d5f812079e0f01e877" + "89f34efdad8098015ee74a4f846dd190d16dc6e1", + .want = + "0100c8935969077bae0ba89ef0df8161d975ec5870ac811a" + "e7e65ca5394efba4f0633d41bf79ea5e5b9496bbd7aae000" + "b0594baa82ef8f244e6984ae87ae1ed124b7", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000000093057fb862f2ad2e82e581baeb3324e7b32946f2b" + "a845a9beeed87d6995f54918ec6619b9931955d5a89d4d74" + "adf1046bb362192f2ef6bd3e3d2d04dd1f87054a", + .peer_y = + "000000aa3fb2448335f694e3cda4ae0cc71b1b2f2a206fa8" + "02d7262f19983c44674fe15327acaac1fa40424c395a6556" + "cb8167312527fae5865ecffc14bbdc17da78cdcf", + .priv = + "0000009012ecfdadc85ced630afea534cdc8e9d1ab8be5f3" + "753dcf5f2b09b40eda66fc6858549bc36e6f8df55998cfa9" + "a0703aecf6c42799c245011064f530c09db98369", + .pub_x = + "000000234e32be0a907131d2d128a6477e0caceb86f02479" + "745e0fe245cb332de631c078871160482eeef584e274df7f" + "a412cea3e1e91f71ecba8781d9205d48386341ad", + .pub_y = + "000001cf86455b09b1c005cffba8d76289a3759628c874be" + "ea462f51f30bd581e3803134307dedbb771b3334ee15be2e" + "242cd79c3407d2f58935456c6941dd9b6d155a46", + .want = + "017f36af19303841d13a389d95ec0b801c7f9a679a823146" + "c75c17bc44256e9ad422a4f8b31f14647b2c7d317b933f7c" + "2946c4b8abd1d56d620fab1b5ff1a3adc71f", + }, + { + .nid = NID_secp521r1, + .peer_x = + "00000083192ed0b1cb31f75817794937f66ad91cf74552cd" + "510cedb9fd641310422af5d09f221cad249ee814d16dd7ac" + "84ded9eacdc28340fcfc9c0c06abe30a2fc28cd8", + .peer_y = + "0000002212ed868c9ba0fb2c91e2c39ba93996a3e4ebf45f" + "2852d0928c48930e875cc7b428d0e7f3f4d503e5d60c68cb" + "49b13c2480cd486bed9200caddaddfe4ff8e3562", + .priv = + "000001b5ff847f8eff20b88cfad42c06e58c3742f2f8f1fd" + "fd64b539ba48c25926926bd5e332b45649c0b184f77255e9" + "d58fe8afa1a6d968e2cb1d4637777120c765c128", + .pub_x = + "000001de3dc9263bc8c4969dc684be0eec54befd9a9f3dba" + "194d8658a789341bf0d78d84da6735227cafaf0935195169" + "1197573c8c360a11e5285712b8bbdf5ac91b977c", + .pub_y = + "000000812de58cd095ec2e5a9b247eb3ed41d8bef6aeace1" + "94a7a05b65aa5d289fbc9b1770ec84bb6be0c2c64cc37c1d" + "54a7f5d71377a9adbe20f26f6f2b544a821ea831", + .want = + "00062f9fc29ae1a68b2ee0dcf956cbd38c88ae5f645eaa54" + "6b00ebe87a7260bf724be20d34b9d02076655c933d056b21" + "e304c24ddb1dedf1dd76de611fc4a2340336", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000001a89b636a93e5d2ba6c2292bf23033a84f06a3ac122" + "0ea71e806afbe097a804cc67e9baa514cfb6c12c9194be30" + "212bf7aae7fdf6d376c212f0554e656463ffab7e", + .peer_y = + "00000182efcaf70fc412d336602e014da47256a0b606f2ad" + "dcce8053bf817ac8656bb4e42f14c8cbf2a68f488ab35dcd" + "f64056271dee1f606a440ba4bd4e5a11b8b8e54f", + .priv = + "0000011a6347d4e801c91923488354cc533e7e35fddf81ff" + "0fb7f56bb0726e0c29ee5dcdc5f394ba54cf57269048aab6" + "e055895c8da24b8b0639a742314390cc04190ed6", + .pub_x = + "000000fe30267f33ba5cdefc25cbb3c9320dad9ccb1d7d37" + "6644620ca4fadee5626a3cede25ad254624def727a7048f7" + "145f76162aa98042f9b123b2076f8e8cf59b3fdf", + .pub_y = + "0000001145dc6631953b6e2945e94301d6cbb098fe4b04f7" + "ee9b09411df104dc82d7d79ec46a01ed0f2d3e7db6eb6806" + "94bdeb107c1078aec6cabd9ebee3d342fe7e54df", + .want = + "0128ab09bfec5406799e610f772ba17e892249fa8e0e7b18" + "a04b9197034b250b48294f1867fb9641518f92766066a07a" + "8b917b0e76879e1011e51ccbd9f540c54d4f", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000017200b3f16a68cbaed2bf78ba8cddfb6cffac262bba" + "00fbc25f9dc72a07ce59372904899f364c44cb264c097b64" + "7d4412bee3e519892d534d9129f8a28f7500fee7", + .peer_y = + "000000baba8d672a4f4a3b63de48b96f56e18df5d68f7d70" + "d5109833f43770d6732e06b39ad60d93e5b43db8789f1ec0" + "aba47286a39ea584235acea757dbf13d53b58364", + .priv = + "00000022b6d2a22d71dfaa811d2d9f9f31fbed27f2e1f3d2" + "39538ddf3e4cc8c39a330266db25b7bc0a9704f17bde7f35" + "92bf5f1f2d4b56013aacc3d8d1bc02f00d3146cc", + .pub_x = + "000000ba38cfbf9fd2518a3f61d43549e7a6a6d28b2be57f" + "fd3e0faceb636b34ed17e044a9f249dae8fc132e937e2d93" + "49cd2ed77bb1049ceb692a2ec5b17ad61502a64c", + .pub_y = + "0000001ec91d3058573fa6c0564a02a1a010160c313bc7c7" + "3510dc983e5461682b5be00dbce7e2c682ad73f29ca822cd" + "c111f68fabe33a7b384a648342c3cdb9f050bcdb", + .want = + "0101e462e9d9159968f6440e956f11dcf2227ae4aea81667" + "122b6af9239a291eb5d6cf5a4087f358525fcacfa46bb2db" + "01a75af1ba519b2d31da33eda87a9d565748", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000004efd5dbd2f979e3831ce98f82355d6ca14a5757842" + "875882990ab85ab9b7352dd6b9b2f4ea9a1e95c3880d65d1" + "f3602f9ca653dc346fac858658d75626f4d4fb08", + .peer_y = + "00000061cf15dbdaa7f31589c98400373da284506d70c89f" + "074ed262a9e28140796b7236c2eef99016085e71552ff488" + "c72b7339fefb7915c38459cb20ab85aec4e45052", + .priv = + "0000005bacfff268acf6553c3c583b464ea36a1d35e2b257" + "a5d49eb3419d5a095087c2fb4d15cf5bf5af816d0f3ff758" + "6490ccd3ddc1a98b39ce63749c6288ce0dbdac7d", + .pub_x = + "00000036e488da7581472a9d8e628c58d6ad727311b7e6a3" + "f6ae33a8544f34b09280249020be7196916fafd90e2ec54b" + "66b5468d2361b99b56fa00d7ac37abb8c6f16653", + .pub_y = + "0000011edb9fb8adb6a43f4f5f5fdc1421c9fe04fc8ba46c" + "9b66334e3af927c8befb4307104f299acec4e30f812d9345" + "c9720d19869dbfffd4ca3e7d2713eb5fc3f42615", + .want = + "0141d6a4b719ab67eaf04a92c0a41e2dda78f4354fb90bdc" + "35202cc7699b9b04d49616f82255debf7bbec045ae58f982" + "a66905fcfae69d689785e38c868eb4a27e7b", + }, + { + .nid = NID_secp521r1, + .peer_x = + "00000129891de0cf3cf82e8c2cf1bf90bb296fe00ab08ca4" + "5bb7892e0e227a504fdd05d2381a4448b68adff9c4153c87" + "eacb78330d8bd52515f9f9a0b58e85f446bb4e10", + .peer_y = + "0000009edd679696d3d1d0ef327f200383253f6413683d9e" + "4fcc87bb35f112c2f110098d15e5701d7ceee416291ff5fe" + "d85e687f727388b9afe26a4f6feed560b218e6bb", + .priv = + "0000008e2c93c5423876223a637cad367c8589da69a2d0fc" + "68612f31923ae50219df2452e7cc92615b67f17b57ffd2f5" + "2b19154bb40d7715336420fde2e89fee244f59dc", + .pub_x = + "000000fa3b35118d6c422570f724a26f90b2833b19239174" + "cea081c53133f64db60d6940ea1261299c04c1f4587cdb0c" + "4c39616479c1bb0c146799a118032dcf98f899c0", + .pub_y = + "00000069f040229006151fa32b51f679c8816f7c17506b40" + "3809dc77cd58a2aec430d94d13b6c916de99f355aa45fcfb" + "c6853d686c71be496a067d24bfaea4818fc51f75", + .want = + "00345e26e0abb1aac12b75f3a9cf41efe1c336396dffa4a0" + "67a4c2cfeb878c68b2b045faa4e5b4e6fa4678f5b603c351" + "903b14bf9a6a70c439257199a640890b61d1", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000001a3c20240e59f5b7a3e17c275d2314ba1741210ad58" + "b71036f8c83cc1f6b0f409dfdd9113e94b67ec39c3291426" + "c23ffcc447054670d2908ff8fe67dc2306034c5c", + .peer_y = + "000001d2825bfd3af8b1e13205780c137fe938f84fde4018" + "8e61ea02cead81badfdb425c29f7d7fb0324debadc10bbb9" + "3de68f62c35069268283f5265865db57a79f7bf7", + .priv = + "00000004d49d39d40d8111bf16d28c5936554326b197353e" + "ebbcf47545393bc8d3aaf98f14f5be7074bfb38e6cc97b98" + "9754074daddb3045f4e4ce745669fdb3ec0d5fa8", + .pub_x = + "0000012ec226d050ce07c79b3df4d0f0891f9f7adf462e8c" + "98dbc1a2a14f5e53a3f5ad894433587cc429a8be9ea1d84f" + "a33b1803690dae04da7218d30026157fc995cf52", + .pub_y = + "0000004837dfbf3426f57b5c793269130abb9a38f6185322" + "11931154db4eeb9aede88e57290f842ea0f2ea9a5f74c620" + "3a3920fe4e305f6118f676b154e1d75b9cb5eb88", + .want = + "006fe9de6fb8e672e7fd150fdc5e617fabb0d43906354ccf" + "d224757c7276f7a1010091b17ed072074f8d10a5ec971eb3" + "5a5cb7076603b7bc38d432cbc059f80f9488", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000007e2d138f2832e345ae8ff65957e40e5ec7163f016b" + "df6d24a2243daa631d878a4a16783990c722382130f9e51f" + "0c1bd6ff5ac96780e48b68f5dec95f42e6144bb5", + .peer_y = + "000000b0de5c896791f52886b0f09913e26e78dd0b69798f" + "c4df6d95e3ca708ecbcbcce1c1895f5561bbabaae372e9e6" + "7e6e1a3be60e19b470cdf673ec1fc393d3426e20", + .priv = + "0000011a5d1cc79cd2bf73ea106f0e60a5ace220813b53e2" + "7b739864334a07c03367efda7a4619fa6eef3a9746492283" + "b3c445610a023a9cc49bf4591140384fca5c8bb5", + .pub_x = + "000000eb07c7332eedb7d3036059d35f7d2288d4377d5f42" + "337ad3964079fb120ccd4c8bd384b585621055217023acd9" + "a94fcb3b965bfb394675e788ade41a1de73e620c", + .pub_y = + "000000491a835de2e6e7deb7e090f4a11f2c460c0b1f3d5e" + "94ee8d751014dc720784fd3b54500c86ebaef18429f09e8e" + "876d5d1538968a030d7715dde99f0d8f06e29d59", + .want = + "01e4e759ecedce1013baf73e6fcc0b92451d03bdd50489b7" + "8871c333114990c9ba6a9b2fc7b1a2d9a1794c1b60d9279a" + "f6f146f0bbfb0683140403bfa4ccdb524a29", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000000118c36022209b1af8ebad1a12b566fc48744576e11" + "99fe80de1cdf851cdf03e5b9091a8f7e079e83b7f827259b" + "691d0c22ee29d6bdf73ec7bbfd746f2cd97a357d", + .peer_y = + "000000da5ff4904548a342e2e7ba6a1f4ee5f840411a96cf" + "63e6fe622f22c13e614e0a847c11a1ab3f1d12cc850c32e0" + "95614ca8f7e2721477b486e9ff40372977c3f65c", + .priv = + "0000010c908caf1be74c616b625fc8c1f514446a6aec83b5" + "937141d6afbb0a8c7666a7746fa1f7a6664a2123e8cdf6cd" + "8bf836c56d3c0ebdcc980e43a186f938f3a78ae7", + .pub_x = + "00000031890f4c7abec3f723362285d77d2636f876817db3" + "bbc88b01e773597b969ff6f013ea470c854ab4a7739004eb" + "8cbea69b82ddf36acadd406871798ecb2ac3aa7f", + .pub_y = + "000000d8b429ae3250266b9643c0c765a60dc10155bc2531" + "cf8627296f4978b6640a9e600e19d0037d58503fa8079954" + "6a814d7478a550aa90e5ebeb052527faaeae5d08", + .want = + "0163c9191d651039a5fe985a0eea1eba018a40ab1937fcd2" + "b61220820ee8f2302e9799f6edfc3f5174f369d672d377ea" + "8954a8d0c8b851e81a56fda95212a6578f0e", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000001780edff1ca1c03cfbe593edc6c049bcb2860294a92" + "c355489d9afb2e702075ade1c953895a456230a0cde905de" + "4a3f38573dbfcccd67ad6e7e93f0b5581e926a5d", + .peer_y = + "000000a5481962c9162962e7f0ebdec936935d0eaa813e82" + "26d40d7f6119bfd940602380c86721e61db1830f51e139f2" + "10000bcec0d8edd39e54d73a9a129f95cd5fa979", + .priv = + "000001b37d6b7288de671360425d3e5ac1ccb21815079d8d" + "73431e9b74a6f0e7ae004a357575b11ad66642ce8b775593" + "eba9d98bf25c75ef0b4d3a2098bbc641f59a2b77", + .pub_x = + "000000189a5ee34de7e35aefeaeef9220c18071b4c29a4c3" + "bd9d954458bd3e82a7a34da34cff5579b8101c065b1f2f52" + "7cf4581501e28ef5671873e65267733d003520af", + .pub_y = + "000001eb4bc50a7b4d4599d7e3fa773ddb9eb252c9b34228" + "72e544bdf75c7bf60f5166ddc11eb08fa7c30822dabaee37" + "3ab468eb2d922e484e2a527fff2ebb804b7d9a37", + .want = + "015d613e267a36342e0d125cdad643d80d97ed0600afb9e6" + "b9545c9e64a98cc6da7c5aaa3a8da0bdd9dd3b97e9788218" + "a80abafc106ef065c8f1c4e1119ef58d298b", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000016dacffa183e5303083a334f765de724ec5ec940202" + "6d4797884a9828a0d321a8cfac74ab737fe20a7d6befcfc7" + "3b6a35c1c7b01d373e31abc192d48a4241a35803", + .peer_y = + "0000011e5327cac22d305e7156e559176e19bee7e4f2f59e" + "86f1a9d0b6603b6a7df1069bde6387feb71587b8ffce5b26" + "6e1bae86de29378a34e5c74b6724c4d40a719923", + .priv = + "000000f2661ac762f60c5fff23be5d969ccd4ec6f98e4e72" + "618d12bdcdb9b4102162333788c0bae59f91cdfc172c7a16" + "81ee44d96ab2135a6e5f3415ebbcd55165b1afb0", + .pub_x = + "000000a8e25a6902d687b4787cdc94c364ac7cecc5c49548" + "3ed363dc0aa95ee2bd739c4c4d46b17006c728b076350d7d" + "7e54c6822f52f47162a25109aaaba690cab696ec", + .pub_y = + "00000168d2f08fe19e4dc9ee7a195b03c9f7fe6676f9f520" + "b6270557504e72ca4394a2c6918625e15ac0c51b8f95cd56" + "0123653fb8e8ee6db961e2c4c62cc54e92e2a2a9", + .want = + "014d6082a3b5ced1ab8ca265a8106f302146c4acb8c30bb1" + "4a4c991e3c82a9731288bdb91e0e85bda313912d06384fc4" + "4f2153fb13506fa9cf43c9aab5750988c943", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000000a091421d3703e3b341e9f1e7d58f8cf7bdbd1798d0" + "01967b801d1cec27e605c580b2387c1cb464f55ce7ac8033" + "4102ab03cfb86d88af76c9f4129c01bedd3bbfc4", + .peer_y = + "0000008c9c577a8e6fc446815e9d40baa66025f15dae285f" + "19eb668ee60ae9c98e7ecdbf2b2a68e22928059f67db1880" + "07161d3ecf397e0883f0c4eb7eaf7827a62205cc", + .priv = + "000000f430ca1261f09681a9282e9e970a9234227b1d5e58" + "d558c3cc6eff44d1bdf53de16ad5ee2b18b92d62fc795861" + "16b0efc15f79340fb7eaf5ce6c44341dcf8dde27", + .pub_x = + "0000006c1d9b5eca87de1fb871a0a32f807c725adccde9b3" + "967453a71347d608f0c030cd09e338cdecbf4a02015bc8a6" + "e8d3e2595fe773ffc2fc4e4a55d0b1a2cc00323b", + .pub_y = + "000001141b2109e7f4981c952aa818a2b9f6f5c41feccdb7" + "a7a45b9b4b672937771b008cae5f934dfe3fed10d383ab1f" + "38769c92ce88d9be5414817ecb073a31ab368ccb", + .want = + "0020c00747cb8d492fd497e0fec54644bf027d418ab68638" + "1f109712a99cabe328b9743d2225836f9ad66e5d7fed1de2" + "47e0da92f60d5b31f9e47672e57f710598f4", + }, + { + .nid = NID_secp521r1, + .peer_x = + "0000004f38816681771289ce0cb83a5e29a1ab06fc91f786" + "994b23708ff08a08a0f675b809ae99e9f9967eb1a49f1960" + "57d69e50d6dedb4dd2d9a81c02bdcc8f7f518460", + .peer_y = + "0000009efb244c8b91087de1eed766500f0e81530752d469" + "256ef79f6b965d8a2232a0c2dbc4e8e1d09214bab38485be" + "6e357c4200d073b52f04e4a16fc6f5247187aecb", + .priv = + "0000005dc33aeda03c2eb233014ee468dff753b72f73b009" + "91043ea353828ae69d4cd0fadeda7bb278b535d7c57406ff" + "2e6e473a5a4ff98e90f90d6dadd25100e8d85666", + .pub_x = + "000000c825ba307373cec8dd2498eef82e21fd9862168dbf" + "eb83593980ca9f82875333899fe94f137daf1c4189eb5029" + "37c3a367ea7951ed8b0f3377fcdf2922021d46a5", + .pub_y = + "0000016b8a2540d5e65493888bc337249e67c0a68774f3e8" + "d81e3b4574a0125165f0bd58b8af9de74b35832539f95c3c" + "d9f1b759408560aa6851ae3ac7555347b0d3b13b", + .want = + "00c2bfafcd7fbd3e2fd1c750fdea61e70bd4787a7e68468c" + "574ee99ebc47eedef064e8944a73bcb7913dbab5d93dca66" + "0d216c553622362794f7a2acc71022bdb16f", + }, + { + .nid = NID_secp521r1, + .peer_x = + "000001a32099b02c0bd85371f60b0dd20890e6c7af048c81" + "79890fda308b359dbbc2b7a832bb8c6526c4af99a7ea3f0b" + "3cb96ae1eb7684132795c478ad6f962e4a6f446d", + .peer_y = + "0000017627357b39e9d7632a1370b3e93c1afb5c851b910e" + "b4ead0c9d387df67cde85003e0e427552f1cd09059aad026" + "2e235cce5fba8cedc4fdc1463da76dcd4b6d1a46", + .priv = + "000000df14b1f1432a7b0fb053965fd8643afee26b2451ec" + "b6a8a53a655d5fbe16e4c64ce8647225eb11e7fdcb236274" + "71dffc5c2523bd2ae89957cba3a57a23933e5a78", + .pub_x = + "0000004e8583bbbb2ecd93f0714c332dff5ab3bc6396e62f" + "3c560229664329baa5138c3bb1c36428abd4e23d17fcb7a2" + "cfcc224b2e734c8941f6f121722d7b6b94154576", + .pub_y = + "000001cf0874f204b0363f020864672fadbf87c8811eb147" + "758b254b74b14fae742159f0f671a018212bbf25b8519e12" + "6d4cad778cfff50d288fd39ceb0cac635b175ec0", + .want = + "01aaf24e5d47e4080c18c55ea35581cd8da30f1a07956504" + "5d2008d51b12d0abb4411cda7a0785b15d149ed301a36970" + "62f42da237aa7f07e0af3fd00eb1800d9c41", + }, +}; + +#define N_ECC_CDH_TESTS (sizeof(ecc_cdh_tests) / sizeof(ecc_cdh_tests[0])) + +static void +hexdump(const unsigned char *buf, size_t len) +{ + size_t i; + + for (i = 1; i <= len; i++) + fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n"); + + if (len % 8) + fprintf(stderr, "\n"); +} + +static int +run_ecc_cdh_test(const struct ecc_cdh_test *test) +{ + static int last_nid; + static size_t count; + EC_KEY *key = NULL; + const EC_GROUP *group; + EC_POINT *peer_pub = NULL; + BN_CTX *ctx = NULL; + BIGNUM *peer_x, *peer_y, *priv, *pub_x, *pub_y, *shared; + uint8_t *out, *want; + int out_len; + int failed = 1; + + if (test->nid != last_nid) { + last_nid = test->nid; + count = 0; + } + + if ((ctx = BN_CTX_new()) == NULL) + errx(1, "BN_CTX_new"); + + BN_CTX_start(ctx); + + if ((peer_x = BN_CTX_get(ctx)) == NULL) + errx(1, "peer_x = BN_CTX_get()"); + if ((peer_y = BN_CTX_get(ctx)) == NULL) + errx(1, "peer_y = BN_CTX_get()"); + if ((priv = BN_CTX_get(ctx)) == NULL) + errx(1, "priv = BN_CTX_get()"); + if ((pub_x = BN_CTX_get(ctx)) == NULL) + errx(1, "pub_x = BN_CTX_get()"); + if ((pub_y = BN_CTX_get(ctx)) == NULL) + errx(1, "pub_y = BN_CTX_get()"); + if ((shared = BN_CTX_get(ctx)) == NULL) + errx(1, "want = BN_CTX_get()"); + + if ((key = EC_KEY_new_by_curve_name(test->nid)) == NULL) + errx(1, "EC_KEY_new_by_curve_name(%d)", test->nid); + + if (!BN_hex2bn(&peer_x, test->peer_x)) + errx(1, "peer_x = BN_hex2bn()"); + if (!BN_hex2bn(&peer_y, test->peer_y)) + errx(1, "peer_y = BN_hex2bn()"); + + if ((group = EC_KEY_get0_group(key)) == NULL) + errx(1, "EC_KEY_get0_group"); + + if ((peer_pub = EC_POINT_new(group)) == NULL) + errx(1, "EC_POINT_new"); + + if (!EC_POINT_set_affine_coordinates(group, peer_pub, peer_x, peer_y, ctx)) + errx(1, "EC_POINT_set_affine_coordinates"); + + if (!BN_hex2bn(&priv, test->priv)) + errx(1, "priv = BN_hex2bn()"); + if (!BN_hex2bn(&pub_x, test->pub_x)) + errx(1, "pub_x = BN_hex2bn()"); + if (!BN_hex2bn(&pub_y, test->pub_y)) + errx(1, "pub_y = BN_hex2bn()"); + + if (!EC_KEY_set_private_key(key, priv)) + errx(1, "EC_KEY_set_private_key"); + if (!EC_KEY_set_public_key_affine_coordinates(key, pub_x, pub_y)) + errx(1, "EC_KEY_set_public_key_affine_coordinates"); + + EC_KEY_set_flags(key, EC_FLAG_COFACTOR_ECDH); + + out_len = ECDH_size(key); + if ((out = calloc(1, out_len)) == NULL) + errx(1, NULL); + + if (ECDH_compute_key(out, out_len, peer_pub, key, NULL) != out_len) + errx(1, "ECDH_compute_key"); + + if (!BN_hex2bn(&shared, test->want)) + errx(1, "shared = BN_hex2bn()"); + + if ((want = calloc(1, out_len)) == NULL) + errx(1, NULL); + + if (BN_bn2binpad(shared, want, out_len) != out_len) + errx(1, "BN_bn2binpad"); + + if (memcmp(out, want, out_len) != 0) { + fprintf(stderr, "%s test %zu failed:\nwant:\n", + OBJ_nid2sn(test->nid), count); + hexdump(want, out_len); + fprintf(stderr, "got:\n"); + hexdump(out, out_len); + goto failed; + } + + failed = 0; + + failed: + count++; + + EC_KEY_free(key); + EC_POINT_free(peer_pub); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + freezero(out, out_len); + freezero(want, out_len); + + return failed; +} + +int +main(void) +{ + int failed = 0; + size_t i; + + for (i = 0; i < N_ECC_CDH_TESTS; i++) + failed |= run_ecc_cdh_test(&ecc_cdh_tests[i]); + + return failed; +} diff --git a/regress/lib/libcrypto/ecdh/ecdhtest.c b/regress/lib/libcrypto/ecdh/ecdhtest.c index 8770e4a8f..7d7bbf546 100644 --- a/regress/lib/libcrypto/ecdh/ecdhtest.c +++ b/regress/lib/libcrypto/ecdh/ecdhtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdhtest.c,v 1.16 2023/05/20 16:00:22 tb Exp $ */ +/* $OpenBSD: ecdhtest.c,v 1.20 2023/07/16 07:34:07 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -67,12 +67,11 @@ * */ +#include #include #include #include -#include -#include #include #include #include @@ -81,350 +80,339 @@ #include #include -static const int KDF1_SHA1_len = 20; +static void +hexdump(const unsigned char *buf, size_t len) +{ + size_t i; + + for (i = 1; i <= len; i++) + fprintf(stdout, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n"); + + if (len % 8) + fprintf(stdout, "\n"); +} + static void * KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen) { -#ifndef OPENSSL_NO_SHA +#ifdef OPENSSL_NO_SHA + return NULL; +#else if (*outlen < SHA_DIGEST_LENGTH) return NULL; - else - *outlen = SHA_DIGEST_LENGTH; + *outlen = SHA_DIGEST_LENGTH; return SHA1(in, inlen, out); -#else - return NULL; #endif } - static int -test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) +ecdh_keygen_test(int nid) { - BIGNUM *x_a = NULL, *y_a = NULL, *x_b = NULL, *y_b = NULL; - EC_KEY *a = NULL, *b = NULL; - const EC_GROUP *group; + EC_KEY *keya = NULL, *keyb = NULL; + const EC_POINT *puba, *pubb; unsigned char *abuf = NULL, *bbuf = NULL; - int i, alen, blen, aout, bout, ret = 0; - char buf[12]; + int len = SHA_DIGEST_LENGTH; + int failed = 1; - a = EC_KEY_new_by_curve_name(nid); - b = EC_KEY_new_by_curve_name(nid); - if (a == NULL || b == NULL) + if ((keya = EC_KEY_new_by_curve_name(nid)) == NULL) + goto err; + if (!EC_KEY_generate_key(keya)) + goto err; + if ((puba = EC_KEY_get0_public_key(keya)) == NULL) goto err; - group = EC_KEY_get0_group(a); - - if ((x_a = BN_new()) == NULL) + if ((keyb = EC_KEY_new_by_curve_name(nid)) == NULL) goto err; - if ((y_a = BN_new()) == NULL) + if (!EC_KEY_generate_key(keyb)) goto err; - if ((x_b = BN_new()) == NULL) - goto err; - if ((y_b = BN_new()) == NULL) + if ((pubb = EC_KEY_get0_public_key(keyb)) == NULL) goto err; - BIO_puts(out, "Testing key generation with "); - BIO_puts(out, text); - (void)BIO_flush(out); - - if (!EC_KEY_generate_key(a)) + if ((abuf = calloc(1, len)) == NULL) + goto err; + if ((bbuf = calloc(1, len)) == NULL) goto err; - if (!EC_POINT_get_affine_coordinates(group, - EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; - - BIO_printf(out, " ."); - (void)BIO_flush(out); - - if (!EC_KEY_generate_key(b)) + if (ECDH_compute_key(abuf, len, pubb, keya, KDF1_SHA1) != len) + goto err; + if (ECDH_compute_key(bbuf, len, puba, keyb, KDF1_SHA1) != len) goto err; - if (!EC_POINT_get_affine_coordinates(group, - EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; + if (memcmp(abuf, bbuf, len) != 0) { + printf("key generation with %s failed\n", OBJ_nid2sn(nid)); - BIO_printf(out, "."); - (void)BIO_flush(out); + EC_KEY_print_fp(stdout, keya, 1); + printf(" shared secret:\n"); + hexdump(abuf, len); - alen = KDF1_SHA1_len; - if ((abuf = malloc(alen)) == NULL) - goto err; - aout = ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), - a, KDF1_SHA1); + EC_KEY_print_fp(stdout, keyb, 1); + printf(" shared secret:\n"); + hexdump(bbuf, len); - BIO_printf(out, "."); - (void)BIO_flush(out); - - blen = KDF1_SHA1_len; - if ((bbuf = malloc(blen)) == NULL) - goto err; - bout = ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), - b, KDF1_SHA1); - - BIO_printf(out, "."); - (void)BIO_flush(out); - - if ((aout < 4) || (bout != aout) || (memcmp(abuf, bbuf, aout) != 0)) { - BIO_printf(out, " failed\n\n"); - BIO_printf(out, "key a:\n"); - BIO_printf(out, "private key: "); - BN_print(out, EC_KEY_get0_private_key(a)); - BIO_printf(out, "\n"); - BIO_printf(out, "public key (x,y): "); - BN_print(out, x_a); - BIO_printf(out, ","); - BN_print(out, y_a); - BIO_printf(out, "\nkey b:\n"); - BIO_printf(out, "private key: "); - BN_print(out, EC_KEY_get0_private_key(b)); - BIO_printf(out, "\n"); - BIO_printf(out, "public key (x,y): "); - BN_print(out, x_b); - BIO_printf(out, ","); - BN_print(out, y_b); - BIO_printf(out, "\n"); - BIO_printf(out, "generated key a: "); - for (i = 0; i < bout; i++) { - snprintf(buf, sizeof buf, "%02X", bbuf[i]); - BIO_puts(out, buf); - } - BIO_printf(out, "\n"); - BIO_printf(out, "generated key b: "); - for (i = 0; i < aout; i++) { - snprintf(buf, sizeof buf, "%02X", abuf[i]); - BIO_puts(out, buf); - } - BIO_printf(out, "\n"); fprintf(stderr, "Error in ECDH routines\n"); - ret = 0; - } else { - BIO_printf(out, " ok\n"); - ret = 1; + + goto err; } -err: + failed = 0; + + err: ERR_print_errors_fp(stderr); - free(abuf); - free(bbuf); - BN_free(x_a); - BN_free(y_a); - BN_free(x_b); - BN_free(y_b); - EC_KEY_free(b); - EC_KEY_free(a); + EC_KEY_free(keya); + EC_KEY_free(keyb); + freezero(abuf, len); + freezero(bbuf, len); - return (ret); + return failed; } -/* Keys and shared secrets from RFC 7027 */ - -static const unsigned char bp256_da[] = { - 0x81, 0xDB, 0x1E, 0xE1, 0x00, 0x15, 0x0F, 0xF2, 0xEA, 0x33, 0x8D, 0x70, - 0x82, 0x71, 0xBE, 0x38, 0x30, 0x0C, 0xB5, 0x42, 0x41, 0xD7, 0x99, 0x50, - 0xF7, 0x7B, 0x06, 0x30, 0x39, 0x80, 0x4F, 0x1D +static const struct ecdh_kat_test { + const int nid; + const char *keya; + const char *keyb; + const char *want; +} ecdh_kat_tests[] = { + /* Keys and shared secrets from RFC 5114 */ + { + .nid = NID_X9_62_prime192v1, + .keya = "323fa3169d8e9c6593f59476bc142000ab5be0e249c43426", + .keyb = "631f95bb4a67632c9c476eee9ab695ab240a0499307fcf62", + .want = "ad420182633f8526bfe954acda376f05e5ff4f837f54febe", + }, + { + .nid = NID_secp224r1, + .keya = "b558eb6c288da707bbb4f8fbae2ab9e9cb62e3bc5c7573e2" + "2e26d37f", + .keyb = "ac3b1add3d9770e6f6a708ee9f3b8e0ab3b480e9f27f85c8" + "8b5e6d18", + .want = "52272f50f46f4edc9151569092f46df2d96ecc3b6dc1714a" + "4ea949fa", + }, + { + .nid = NID_X9_62_prime256v1, + .keya = "814264145f2f56f2e96a8e337a1284993faf432a5abce59e" + "867b7291d507a3af", + .keyb = "2ce1788ec197e096db95a200cc0ab26a19ce6bccad562b8e" + "ee1b593761cf7f41", + .want = "dd0f5396219d1ea393310412d19a08f1f5811e9dc8ec8eea" + "7f80d21c820c2788", + }, + { + .nid = NID_secp384r1, + .keya = "d27335ea71664af244dd14e9fd1260715dfd8a7965571c48" + "d709ee7a7962a156d706a90cbcb5df2986f05feadb9376f1", + .keyb = "52d1791fdb4b70f89c0f00d456c2f7023b6125262c36a7df" + "1f80231121cce3d39be52e00c194a4132c4a6c768bcd94d2", + .want = "5ea1fc4af7256d2055981b110575e0a8cae53160137d904c" + "59d926eb1b8456e427aa8a4540884c37de159a58028abc0e", + }, + { + .nid = NID_secp521r1, + .keya = "0113f82da825735e3d97276683b2b74277bad27335ea7166" + "4af2430cc4f33459b9669ee78b3ffb9b8683015d344dcbfe" + "f6fb9af4c6c470be254516cd3c1a1fb47362", + .keyb = "00cee3480d8645a17d249f2776d28bae616952d1791fdb4b" + "70f7c3378732aa1b22928448bcd1dc2496d435b01048066e" + "be4f72903c361b1a9dc1193dc2c9d0891b96", + .want = "00cdea89621cfa46b132f9e4cfe2261cde2d4368eb565663" + "4c7cc98c7a00cde54ed1866a0dd3e6126c9d2f845daff82c" + "eb1da08f5d87521bb0ebeca77911169c20cc", + }, + /* Keys and shared secrets from RFC 5903 */ + { + .nid = NID_X9_62_prime256v1, + .keya = "c88f01f510d9ac3f70a292daa2316de544e9aab8afe84049" + "c62a9c57862d1433", + .keyb = "c6ef9c5d78ae012a011164acb397ce2088685d8f06bf9be0" + "b283ab46476bee53", + .want = "d6840f6b42f6edafd13116e0e12565202fef8e9ece7dce03" + "812464d04b9442de", + }, + { + .nid = NID_secp384r1, + .keya = "099f3c7034d4a2c699884d73a375a67f7624ef7c6b3c0f16" + "0647b67414dce655e35b538041e649ee3faef896783ab194", + .keyb = "41cb0779b4bdb85d47846725fbec3c9430fab46cc8dc5060" + "855cc9bda0aa2942e0308312916b8ed2960e4bd55a7448fc", + .want = "11187331c279962d93d604243fd592cb9d0a926f422e4718" + "7521287e7156c5c4d603135569b9e9d09cf5d4a270f59746", + }, + { + .nid = NID_secp521r1, + .keya = "0037ade9319a89f4dabdb3ef411aaccca5123c61acab57b5" + "393dce47608172a095aa85a30fe1c2952c6771d937ba9777" + "f5957b2639bab072462f68c27a57382d" + "4a52", + .keyb = "0145ba99a847af43793fdd0e872e7cdfa16be30fdc780f97" + "bccc3f078380201e9c677d600b343757a3bdbf2a3163e4c2" + "f869cca7458aa4a4effc311f5cb151685eb9", + .want = "01144c7d79ae6956bc8edb8e7c787c4521cb086fa64407f9" + "7894e5e6b2d79b04d1427e73ca4baa240a34786859810c06" + "b3c715a3a8cc3151f2bee417996d19f3ddea", + }, + /* Keys and shared secrets from RFC 7027 */ + { + .nid = NID_brainpoolP256r1, + .keya = "81db1ee100150ff2ea338d708271be38300cb54241d79950" + "f77b063039804f1d", + .keyb = "55e40bc41e37e3e2ad25c3c6654511ffa8474a91a0032087" + "593852d3e7d76bd3", + .want = "89afc39d41d3b327814b80940b042590f96556ec91e6ae79" + "39bce31f3a18bf2b", + }, + { + .nid = NID_brainpoolP384r1, + .keya = "1e20f5e048a5886f1f157c74e91bde2b98c8b52d58e5003d" + "57053fc4b0bd65d6f15eb5d1ee1610df870795143627d042", + .keyb = "032640bc6003c59260f7250c3db58ce647f98e1260acce4a" + "cda3dd869f74e01f8ba5e0324309db6a9831497abac96670", + .want = "0bd9d3a7ea0b3d519d09d8e48d0785fb744a6b355e6304bc" + "51c229fbbce239bbadf6403715c35d4fb2a5444f575d4f42", + }, + { + .nid = NID_brainpoolP512r1, + .keya = "16302ff0dbbb5a8d733dab7141c1b45acbc8715939677f6a" + "56850a38bd87bd59b09e80279609ff333eb9d4c061231fb2" + "6f92eeb04982a5f1d1764cad57665422", + .keyb = "230e18e1bcc88a362fa54e4ea3902009292f7f8033624fd4" + "71b5d8ace49d12cfabbc19963dab8e2f1eba00bffb29e4d7" + "2d13f2224562f405cb80503666b25429", + .want = "a7927098655f1f9976fa50a9d566865dc530331846381c87" + "256baf3226244b76d36403c024d7bbf0aa0803eaff405d3d" + "24f11a9b5c0bef679fe1454b21c4cd1f", + }, }; -static const unsigned char bp256_db[] = { - 0x55, 0xE4, 0x0B, 0xC4, 0x1E, 0x37, 0xE3, 0xE2, 0xAD, 0x25, 0xC3, 0xC6, - 0x65, 0x45, 0x11, 0xFF, 0xA8, 0x47, 0x4A, 0x91, 0xA0, 0x03, 0x20, 0x87, - 0x59, 0x38, 0x52, 0xD3, 0xE7, 0xD7, 0x6B, 0xD3 -}; - -static const unsigned char bp256_Z[] = { - 0x89, 0xAF, 0xC3, 0x9D, 0x41, 0xD3, 0xB3, 0x27, 0x81, 0x4B, 0x80, 0x94, - 0x0B, 0x04, 0x25, 0x90, 0xF9, 0x65, 0x56, 0xEC, 0x91, 0xE6, 0xAE, 0x79, - 0x39, 0xBC, 0xE3, 0x1F, 0x3A, 0x18, 0xBF, 0x2B -}; - -static const unsigned char bp384_da[] = { - 0x1E, 0x20, 0xF5, 0xE0, 0x48, 0xA5, 0x88, 0x6F, 0x1F, 0x15, 0x7C, 0x74, - 0xE9, 0x1B, 0xDE, 0x2B, 0x98, 0xC8, 0xB5, 0x2D, 0x58, 0xE5, 0x00, 0x3D, - 0x57, 0x05, 0x3F, 0xC4, 0xB0, 0xBD, 0x65, 0xD6, 0xF1, 0x5E, 0xB5, 0xD1, - 0xEE, 0x16, 0x10, 0xDF, 0x87, 0x07, 0x95, 0x14, 0x36, 0x27, 0xD0, 0x42 -}; - -static const unsigned char bp384_db[] = { - 0x03, 0x26, 0x40, 0xBC, 0x60, 0x03, 0xC5, 0x92, 0x60, 0xF7, 0x25, 0x0C, - 0x3D, 0xB5, 0x8C, 0xE6, 0x47, 0xF9, 0x8E, 0x12, 0x60, 0xAC, 0xCE, 0x4A, - 0xCD, 0xA3, 0xDD, 0x86, 0x9F, 0x74, 0xE0, 0x1F, 0x8B, 0xA5, 0xE0, 0x32, - 0x43, 0x09, 0xDB, 0x6A, 0x98, 0x31, 0x49, 0x7A, 0xBA, 0xC9, 0x66, 0x70 -}; - -static const unsigned char bp384_Z[] = { - 0x0B, 0xD9, 0xD3, 0xA7, 0xEA, 0x0B, 0x3D, 0x51, 0x9D, 0x09, 0xD8, 0xE4, - 0x8D, 0x07, 0x85, 0xFB, 0x74, 0x4A, 0x6B, 0x35, 0x5E, 0x63, 0x04, 0xBC, - 0x51, 0xC2, 0x29, 0xFB, 0xBC, 0xE2, 0x39, 0xBB, 0xAD, 0xF6, 0x40, 0x37, - 0x15, 0xC3, 0x5D, 0x4F, 0xB2, 0xA5, 0x44, 0x4F, 0x57, 0x5D, 0x4F, 0x42 -}; - -static const unsigned char bp512_da[] = { - 0x16, 0x30, 0x2F, 0xF0, 0xDB, 0xBB, 0x5A, 0x8D, 0x73, 0x3D, 0xAB, 0x71, - 0x41, 0xC1, 0xB4, 0x5A, 0xCB, 0xC8, 0x71, 0x59, 0x39, 0x67, 0x7F, 0x6A, - 0x56, 0x85, 0x0A, 0x38, 0xBD, 0x87, 0xBD, 0x59, 0xB0, 0x9E, 0x80, 0x27, - 0x96, 0x09, 0xFF, 0x33, 0x3E, 0xB9, 0xD4, 0xC0, 0x61, 0x23, 0x1F, 0xB2, - 0x6F, 0x92, 0xEE, 0xB0, 0x49, 0x82, 0xA5, 0xF1, 0xD1, 0x76, 0x4C, 0xAD, - 0x57, 0x66, 0x54, 0x22 -}; - -static const unsigned char bp512_db[] = { - 0x23, 0x0E, 0x18, 0xE1, 0xBC, 0xC8, 0x8A, 0x36, 0x2F, 0xA5, 0x4E, 0x4E, - 0xA3, 0x90, 0x20, 0x09, 0x29, 0x2F, 0x7F, 0x80, 0x33, 0x62, 0x4F, 0xD4, - 0x71, 0xB5, 0xD8, 0xAC, 0xE4, 0x9D, 0x12, 0xCF, 0xAB, 0xBC, 0x19, 0x96, - 0x3D, 0xAB, 0x8E, 0x2F, 0x1E, 0xBA, 0x00, 0xBF, 0xFB, 0x29, 0xE4, 0xD7, - 0x2D, 0x13, 0xF2, 0x22, 0x45, 0x62, 0xF4, 0x05, 0xCB, 0x80, 0x50, 0x36, - 0x66, 0xB2, 0x54, 0x29 -}; - - -static const unsigned char bp512_Z[] = { - 0xA7, 0x92, 0x70, 0x98, 0x65, 0x5F, 0x1F, 0x99, 0x76, 0xFA, 0x50, 0xA9, - 0xD5, 0x66, 0x86, 0x5D, 0xC5, 0x30, 0x33, 0x18, 0x46, 0x38, 0x1C, 0x87, - 0x25, 0x6B, 0xAF, 0x32, 0x26, 0x24, 0x4B, 0x76, 0xD3, 0x64, 0x03, 0xC0, - 0x24, 0xD7, 0xBB, 0xF0, 0xAA, 0x08, 0x03, 0xEA, 0xFF, 0x40, 0x5D, 0x3D, - 0x24, 0xF1, 0x1A, 0x9B, 0x5C, 0x0B, 0xEF, 0x67, 0x9F, 0xE1, 0x45, 0x4B, - 0x21, 0xC4, 0xCD, 0x1F -}; +#define N_KATS (sizeof(ecdh_kat_tests) / sizeof(ecdh_kat_tests[0])) /* Given private value and NID, create EC_KEY structure */ static EC_KEY * -mk_eckey(int nid, const unsigned char *p, size_t plen) +mk_eckey(int nid, const char *priv_str) { - EC_KEY *k = NULL; + EC_KEY *key = NULL; BIGNUM *priv = NULL; EC_POINT *pub = NULL; - const EC_GROUP *grp; - int ok = 0; + const EC_GROUP *group; + EC_KEY *ret = NULL; - k = EC_KEY_new_by_curve_name(nid); - if (!k) + if ((key = EC_KEY_new_by_curve_name(nid)) == NULL) goto err; - priv = BN_bin2bn(p, plen, NULL); - if (!priv) + if (!BN_hex2bn(&priv, priv_str)) goto err; - if (!EC_KEY_set_private_key(k, priv)) + if (!EC_KEY_set_private_key(key, priv)) goto err; - grp = EC_KEY_get0_group(k); - pub = EC_POINT_new(grp); - if (!pub) + if ((group = EC_KEY_get0_group(key)) == NULL) goto err; - if (!EC_POINT_mul(grp, pub, priv, NULL, NULL, NULL)) + if ((pub = EC_POINT_new(group)) == NULL) goto err; - if (!EC_KEY_set_public_key(k, pub)) + if (!EC_POINT_mul(group, pub, priv, NULL, NULL, NULL)) goto err; - ok = 1; -err: + if (!EC_KEY_set_public_key(key, pub)) + goto err; + + ret = key; + key = NULL; + + err: + EC_KEY_free(key); BN_free(priv); EC_POINT_free(pub); - if (!ok) { - EC_KEY_free(k); - k = NULL; - } - return (k); + + return ret; } -/* Known answer test: compute shared secret and check it matches - * expected value. +/* + * Known answer test: compute shared secret and check it matches expected value. */ - static int -ecdh_kat(BIO *out, const char *cname, int nid, - const unsigned char *k1, size_t k1_len, - const unsigned char *k2, size_t k2_len, - const unsigned char *Z, size_t Zlen) +ecdh_kat(const struct ecdh_kat_test *kat) { - int rv = 0; - EC_KEY *key1 = NULL, *key2 = NULL; - unsigned char *Ztmp = NULL; - size_t Ztmplen; - BIO_puts(out, "Testing ECDH shared secret with "); - BIO_puts(out, cname); - key1 = mk_eckey(nid, k1, k1_len); - key2 = mk_eckey(nid, k2, k2_len); - if (!key1 || !key2) - goto err; - Ztmplen = ECDH_size(key1); - if (Ztmplen != Zlen) - goto err; - if ((Ztmp = malloc(Ztmplen)) == NULL) - goto err; - if (!ECDH_compute_key(Ztmp, Ztmplen, - EC_KEY_get0_public_key(key2), key1, 0)) - goto err; - if (memcmp(Ztmp, Z, Zlen)) - goto err; - memset(Ztmp, 0, Zlen); - if (!ECDH_compute_key(Ztmp, Ztmplen, - EC_KEY_get0_public_key(key1), key2, 0)) - goto err; - if (memcmp(Ztmp, Z, Zlen)) - goto err; - rv = 1; + EC_KEY *keya = NULL, *keyb = NULL; + const EC_POINT *puba, *pubb; + BIGNUM *z = NULL; + unsigned char *want = NULL, *got = NULL; + int len = 0; + int failed = 1; + + if ((keya = mk_eckey(kat->nid, kat->keya)) == NULL) + goto err; + if ((puba = EC_KEY_get0_public_key(keya)) == NULL) + goto err; + if ((keyb = mk_eckey(kat->nid, kat->keyb)) == NULL) + goto err; + if ((pubb = EC_KEY_get0_public_key(keyb)) == NULL) + goto err; + + if ((len = ECDH_size(keya)) != ECDH_size(keyb)) + goto err; + + if ((want = calloc(1, len)) == NULL) + goto err; + if ((got = calloc(1, len)) == NULL) + goto err; + + if (!BN_hex2bn(&z, kat->want)) + goto err; + if (BN_num_bytes(z) > len) + goto err; + if (BN_bn2binpad(z, want, len) != len) + goto err; + + if (ECDH_compute_key(got, len, pubb, keya, NULL) != len) + goto err; + if (memcmp(got, want, len) != 0) + goto err; + + memset(got, 0, len); + + if (ECDH_compute_key(got, len, puba, keyb, NULL) != len) + goto err; + if (memcmp(got, want, len) != 0) + goto err; + + failed = 0; + + err: + if (failed) { + printf("shared secret with %s failed", OBJ_nid2sn(kat->nid)); -err: - if (rv) - BIO_puts(out, " ok\n"); - else { fprintf(stderr, "Error in ECDH routines\n"); ERR_print_errors_fp(stderr); } - EC_KEY_free(key1); - EC_KEY_free(key2); - free(Ztmp); + EC_KEY_free(keya); + EC_KEY_free(keyb); + BN_free(z); + freezero(want, len); + freezero(got, len); - return rv; + return failed; } -#define test_ecdh_kat(bio, curve, bits) \ - ecdh_kat(bio, curve, NID_brainpoolP##bits##r1, \ - bp##bits##_da, sizeof(bp##bits##_da), \ - bp##bits##_db, sizeof(bp##bits##_db), \ - bp##bits##_Z, sizeof(bp##bits##_Z)) - int -main(int argc, char *argv[]) +main(void) { - BN_CTX *ctx = NULL; - int ret = 1; - BIO *out; + EC_builtin_curve *curves = NULL; + size_t i, n_curves; + int failed = 0; - out = BIO_new(BIO_s_file()); - if (out == NULL) - exit(1); - BIO_set_fp(out, stdout, BIO_NOCLOSE); + if ((n_curves = EC_get_builtin_curves(NULL, 0)) == 0) + errx(1, "EC_get_builtin_curves failed"); + if ((curves = calloc(n_curves, sizeof(*curves))) == NULL) + errx(1, NULL); + if (EC_get_builtin_curves(curves, n_curves) != n_curves) + errx(1, "EC_get_builtin_curves failed"); - if ((ctx = BN_CTX_new()) == NULL) - goto err; + for (i = 0; i < n_curves; i++) + failed |= ecdh_keygen_test(curves[i].nid); - /* NIST PRIME CURVES TESTS */ - if (!test_ecdh_curve(NID_X9_62_prime192v1, "NIST Prime-Curve P-192", - ctx, out)) - goto err; - if (!test_ecdh_curve(NID_secp224r1, "NIST Prime-Curve P-224", ctx, out)) - goto err; - if (!test_ecdh_curve(NID_X9_62_prime256v1, "NIST Prime-Curve P-256", - ctx, out)) - goto err; - if (!test_ecdh_curve(NID_secp384r1, "NIST Prime-Curve P-384", ctx, out)) - goto err; - if (!test_ecdh_curve(NID_secp521r1, "NIST Prime-Curve P-521", ctx, out)) - goto err; - if (!test_ecdh_kat(out, "Brainpool Prime-Curve brainpoolP256r1", 256)) - goto err; - if (!test_ecdh_kat(out, "Brainpool Prime-Curve brainpoolP384r1", 384)) - goto err; - if (!test_ecdh_kat(out, "Brainpool Prime-Curve brainpoolP512r1", 512)) - goto err; + for (i = 0; i < N_KATS; i++) + failed |= ecdh_kat(&ecdh_kat_tests[i]); - ret = 0; - -err: + free(curves); ERR_print_errors_fp(stderr); - BN_CTX_free(ctx); - BIO_free(out); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - CRYPTO_mem_leaks_fp(stderr); - exit(ret); + + return failed; } diff --git a/regress/lib/libcrypto/free/freenull.awk b/regress/lib/libcrypto/free/freenull.awk index 95719da95..41527ac22 100644 --- a/regress/lib/libcrypto/free/freenull.awk +++ b/regress/lib/libcrypto/free/freenull.awk @@ -1,4 +1,4 @@ -# $OpenBSD: freenull.awk,v 1.1 2018/07/10 20:53:30 tb Exp $ +# $OpenBSD: freenull.awk,v 1.2 2023/07/20 17:27:54 tb Exp $ # Copyright (c) 2018 Theo Buehler # # Permission to use, copy, modify, and distribute this software for any @@ -30,7 +30,6 @@ /^OBJ_sigid_free$/ || /^X509V3_section_free$/ || /^X509V3_string_free$/ || -/^asn1_enc_free$/ || /^sk_pop_free$/ { next } @@ -41,8 +40,6 @@ /^EC_PRIVATEKEY_free$/ || /^ECPARAMETERS_free$/ || /^ECPKPARAMETERS_free$/ || -/^NETSCAPE_ENCRYPTED_PKEY_free$/ || -/^NETSCAPE_PKEY_free$/ || /^X9_62_CHARACTERISTIC_TWO_free$/ || /^X9_62_PENTANOMIAL_free$/ { next diff --git a/regress/lib/libcrypto/sha/sha_test.c b/regress/lib/libcrypto/sha/sha_test.c index a04120e4d..82a0c4cce 100644 --- a/regress/lib/libcrypto/sha/sha_test.c +++ b/regress/lib/libcrypto/sha/sha_test.c @@ -1,6 +1,6 @@ -/* $OpenBSD: sha_test.c,v 1.4 2022/09/02 13:23:05 tb Exp $ */ +/* $OpenBSD: sha_test.c,v 1.6 2023/07/19 15:11:42 joshua Exp $ */ /* - * Copyright (c) 2022 Joshua Sing + * Copyright (c) 2022, 2023 Joshua Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -38,7 +38,7 @@ static const struct sha_test sha_tests[] = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d, - } + }, }, { .algorithm = NID_sha1, @@ -48,7 +48,7 @@ static const struct sha_test sha_tests[] = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09, - } + }, }, { .algorithm = NID_sha1, @@ -60,7 +60,7 @@ static const struct sha_test sha_tests[] = { 0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae, 0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1, - } + }, }, { .algorithm = NID_sha1, @@ -73,7 +73,7 @@ static const struct sha_test sha_tests[] = { 0xa4, 0x9b, 0x24, 0x46, 0xa0, 0x2c, 0x64, 0x5b, 0xf4, 0x19, 0xf9, 0x95, 0xb6, 0x70, 0x91, 0x25, 0x3a, 0x04, 0xa2, 0x59, - } + }, }, /* SHA-224 */ @@ -86,7 +86,7 @@ static const struct sha_test sha_tests[] = { 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3, 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7, 0xe3, 0x6c, 0x9d, 0xa7, - } + }, }, { .algorithm = NID_sha224, @@ -97,7 +97,7 @@ static const struct sha_test sha_tests[] = { 0x47, 0x61, 0x02, 0xbb, 0x28, 0x82, 0x34, 0xc4, 0x15, 0xa2, 0xb0, 0x1f, 0x82, 0x8e, 0xa6, 0x2a, 0xc5, 0xb3, 0xe4, 0x2f, - } + }, }, { .algorithm = NID_sha224, @@ -110,7 +110,7 @@ static const struct sha_test sha_tests[] = { 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50, 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19, 0x52, 0x52, 0x25, 0x25, - } + }, }, { .algorithm = NID_sha224, @@ -124,7 +124,7 @@ static const struct sha_test sha_tests[] = { 0x7a, 0x04, 0xa9, 0x6d, 0xef, 0x6d, 0x99, 0xa9, 0xe0, 0xe0, 0xe2, 0xab, 0x14, 0xe6, 0xb8, 0xdf, 0x26, 0x5f, 0xc0, 0xb3, - } + }, }, /* SHA-256 */ @@ -137,7 +137,7 @@ static const struct sha_test sha_tests[] = { 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad, - } + }, }, { .algorithm = NID_sha256, @@ -148,7 +148,7 @@ static const struct sha_test sha_tests[] = { 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55, - } + }, }, { .algorithm = NID_sha256, @@ -161,7 +161,7 @@ static const struct sha_test sha_tests[] = { 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1, - } + }, }, { .algorithm = NID_sha256, @@ -175,7 +175,7 @@ static const struct sha_test sha_tests[] = { 0x03, 0x6c, 0xe5, 0x9e, 0x7b, 0x04, 0x92, 0x37, 0x0b, 0x24, 0x9b, 0x11, 0xe8, 0xf0, 0x7a, 0x51, 0xaf, 0xac, 0x45, 0x03, 0x7a, 0xfe, 0xe9, 0xd1, - } + }, }, /* SHA-384 */ @@ -190,7 +190,7 @@ static const struct sha_test sha_tests[] = { 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed, 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7, - } + }, }, { .algorithm = NID_sha384, @@ -203,7 +203,7 @@ static const struct sha_test sha_tests[] = { 0x4c, 0x0c, 0xc7, 0xbf, 0x63, 0xf6, 0xe1, 0xda, 0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb, 0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b, - } + }, }, { .algorithm = NID_sha384, @@ -218,7 +218,7 @@ static const struct sha_test sha_tests[] = { 0xfe, 0x8f, 0x45, 0x0d, 0xe5, 0xf3, 0x6b, 0xc6, 0xb0, 0x45, 0x5a, 0x85, 0x20, 0xbc, 0x4e, 0x6f, 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b, - } + }, }, { .algorithm = NID_sha384, @@ -234,7 +234,7 @@ static const struct sha_test sha_tests[] = { 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39, - } + }, }, /* SHA-512 */ @@ -251,7 +251,7 @@ static const struct sha_test sha_tests[] = { 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd, 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f, - } + }, }, { .algorithm = NID_sha512, @@ -266,7 +266,7 @@ static const struct sha_test sha_tests[] = { 0xff, 0x83, 0x18, 0xd2, 0x87, 0x7e, 0xec, 0x2f, 0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81, 0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e, - } + }, }, { .algorithm = NID_sha512, @@ -283,7 +283,7 @@ static const struct sha_test sha_tests[] = { 0xaa, 0x1d, 0x3b, 0xea, 0x57, 0x78, 0x9c, 0xa0, 0x31, 0xad, 0x85, 0xc7, 0xa7, 0x1d, 0xd7, 0x03, 0x54, 0xec, 0x63, 0x12, 0x38, 0xca, 0x34, 0x45, - } + }, }, { .algorithm = NID_sha512, @@ -301,7 +301,235 @@ static const struct sha_test sha_tests[] = { 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a, 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54, 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09, - } + }, + }, + + /* SHA3-224 */ + { + .algorithm = NID_sha3_224, + .in = "abc", + .in_len = 3, + .out = { + 0xe6, 0x42, 0x82, 0x4c, 0x3f, 0x8c, 0xf2, 0x4a, + 0xd0, 0x92, 0x34, 0xee, 0x7d, 0x3c, 0x76, 0x6f, + 0xc9, 0xa3, 0xa5, 0x16, 0x8d, 0x0c, 0x94, 0xad, + 0x73, 0xb4, 0x6f, 0xdf, + }, + }, + { + .algorithm = NID_sha3_224, + .in = "", + .in_len = 0, + .out = { + 0x6b, 0x4e, 0x03, 0x42, 0x36, 0x67, 0xdb, 0xb7, + 0x3b, 0x6e, 0x15, 0x45, 0x4f, 0x0e, 0xb1, 0xab, + 0xd4, 0x59, 0x7f, 0x9a, 0x1b, 0x07, 0x8e, 0x3f, + 0x5b, 0x5a, 0x6b, 0xc7, + }, + }, + { + .algorithm = NID_sha3_224, + .in = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno" + "mnopnopq", + .in_len = 56, + .out = { + 0x8a, 0x24, 0x10, 0x8b, 0x15, 0x4a, 0xda, 0x21, + 0xc9, 0xfd, 0x55, 0x74, 0x49, 0x44, 0x79, 0xba, + 0x5c, 0x7e, 0x7a, 0xb7, 0x6e, 0xf2, 0x64, 0xea, + 0xd0, 0xfc, 0xce, 0x33, + }, + }, + { + .algorithm = NID_sha3_224, + .in = + "abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu", + .in_len = 112, + .out = { + 0x54, 0x3e, 0x68, 0x68, 0xe1, 0x66, 0x6c, 0x1a, + 0x64, 0x36, 0x30, 0xdf, 0x77, 0x36, 0x7a, 0xe5, + 0xa6, 0x2a, 0x85, 0x07, 0x0a, 0x51, 0xc1, 0x4c, + 0xbf, 0x66, 0x5c, 0xbc, + }, + }, + + /* SHA3-256 */ + { + .algorithm = NID_sha3_256, + .in = "abc", + .in_len = 3, + .out = { + 0x3a, 0x98, 0x5d, 0xa7, 0x4f, 0xe2, 0x25, 0xb2, + 0x04, 0x5c, 0x17, 0x2d, 0x6b, 0xd3, 0x90, 0xbd, + 0x85, 0x5f, 0x08, 0x6e, 0x3e, 0x9d, 0x52, 0x5b, + 0x46, 0xbf, 0xe2, 0x45, 0x11, 0x43, 0x15, 0x32, + }, + }, + { + .algorithm = NID_sha3_256, + .in = "", + .in_len = 0, + .out = { + 0xa7, 0xff, 0xc6, 0xf8, 0xbf, 0x1e, 0xd7, 0x66, + 0x51, 0xc1, 0x47, 0x56, 0xa0, 0x61, 0xd6, 0x62, + 0xf5, 0x80, 0xff, 0x4d, 0xe4, 0x3b, 0x49, 0xfa, + 0x82, 0xd8, 0x0a, 0x4b, 0x80, 0xf8, 0x43, 0x4a, + }, + }, + { + .algorithm = NID_sha3_256, + .in = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno" + "mnopnopq", + .in_len = 56, + .out = { + 0x41, 0xc0, 0xdb, 0xa2, 0xa9, 0xd6, 0x24, 0x08, + 0x49, 0x10, 0x03, 0x76, 0xa8, 0x23, 0x5e, 0x2c, + 0x82, 0xe1, 0xb9, 0x99, 0x8a, 0x99, 0x9e, 0x21, + 0xdb, 0x32, 0xdd, 0x97, 0x49, 0x6d, 0x33, 0x76, + }, + }, + { + .algorithm = NID_sha3_256, + .in = + "abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu", + .in_len = 112, + .out = { + 0x91, 0x6f, 0x60, 0x61, 0xfe, 0x87, 0x97, 0x41, + 0xca, 0x64, 0x69, 0xb4, 0x39, 0x71, 0xdf, 0xdb, + 0x28, 0xb1, 0xa3, 0x2d, 0xc3, 0x6c, 0xb3, 0x25, + 0x4e, 0x81, 0x2b, 0xe2, 0x7a, 0xad, 0x1d, 0x18, + }, + }, + + /* SHA3-384 */ + { + .algorithm = NID_sha3_384, + .in = "abc", + .in_len = 3, + .out = { + 0xec, 0x01, 0x49, 0x82, 0x88, 0x51, 0x6f, 0xc9, + 0x26, 0x45, 0x9f, 0x58, 0xe2, 0xc6, 0xad, 0x8d, + 0xf9, 0xb4, 0x73, 0xcb, 0x0f, 0xc0, 0x8c, 0x25, + 0x96, 0xda, 0x7c, 0xf0, 0xe4, 0x9b, 0xe4, 0xb2, + 0x98, 0xd8, 0x8c, 0xea, 0x92, 0x7a, 0xc7, 0xf5, + 0x39, 0xf1, 0xed, 0xf2, 0x28, 0x37, 0x6d, 0x25, + }, + }, + { + .algorithm = NID_sha3_384, + .in = "", + .in_len = 0, + .out = { + 0x0c, 0x63, 0xa7, 0x5b, 0x84, 0x5e, 0x4f, 0x7d, + 0x01, 0x10, 0x7d, 0x85, 0x2e, 0x4c, 0x24, 0x85, + 0xc5, 0x1a, 0x50, 0xaa, 0xaa, 0x94, 0xfc, 0x61, + 0x99, 0x5e, 0x71, 0xbb, 0xee, 0x98, 0x3a, 0x2a, + 0xc3, 0x71, 0x38, 0x31, 0x26, 0x4a, 0xdb, 0x47, + 0xfb, 0x6b, 0xd1, 0xe0, 0x58, 0xd5, 0xf0, 0x04, + }, + }, + { + .algorithm = NID_sha3_384, + .in = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno" + "mnopnopq", + .in_len = 56, + .out = { + 0x99, 0x1c, 0x66, 0x57, 0x55, 0xeb, 0x3a, 0x4b, + 0x6b, 0xbd, 0xfb, 0x75, 0xc7, 0x8a, 0x49, 0x2e, + 0x8c, 0x56, 0xa2, 0x2c, 0x5c, 0x4d, 0x7e, 0x42, + 0x9b, 0xfd, 0xbc, 0x32, 0xb9, 0xd4, 0xad, 0x5a, + 0xa0, 0x4a, 0x1f, 0x07, 0x6e, 0x62, 0xfe, 0xa1, + 0x9e, 0xef, 0x51, 0xac, 0xd0, 0x65, 0x7c, 0x22, + }, + }, + { + .algorithm = NID_sha3_384, + .in = + "abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu", + .in_len = 112, + .out = { + 0x79, 0x40, 0x7d, 0x3b, 0x59, 0x16, 0xb5, 0x9c, + 0x3e, 0x30, 0xb0, 0x98, 0x22, 0x97, 0x47, 0x91, + 0xc3, 0x13, 0xfb, 0x9e, 0xcc, 0x84, 0x9e, 0x40, + 0x6f, 0x23, 0x59, 0x2d, 0x04, 0xf6, 0x25, 0xdc, + 0x8c, 0x70, 0x9b, 0x98, 0xb4, 0x3b, 0x38, 0x52, + 0xb3, 0x37, 0x21, 0x61, 0x79, 0xaa, 0x7f, 0xc7, + }, + }, + + /* SHA3-512 */ + { + .algorithm = NID_sha3_512, + .in = "abc", + .in_len = 3, + .out = { + 0xb7, 0x51, 0x85, 0x0b, 0x1a, 0x57, 0x16, 0x8a, + 0x56, 0x93, 0xcd, 0x92, 0x4b, 0x6b, 0x09, 0x6e, + 0x08, 0xf6, 0x21, 0x82, 0x74, 0x44, 0xf7, 0x0d, + 0x88, 0x4f, 0x5d, 0x02, 0x40, 0xd2, 0x71, 0x2e, + 0x10, 0xe1, 0x16, 0xe9, 0x19, 0x2a, 0xf3, 0xc9, + 0x1a, 0x7e, 0xc5, 0x76, 0x47, 0xe3, 0x93, 0x40, + 0x57, 0x34, 0x0b, 0x4c, 0xf4, 0x08, 0xd5, 0xa5, + 0x65, 0x92, 0xf8, 0x27, 0x4e, 0xec, 0x53, 0xf0, + }, + }, + { + .algorithm = NID_sha3_512, + .in = "", + .in_len = 0, + .out = { + 0xa6, 0x9f, 0x73, 0xcc, 0xa2, 0x3a, 0x9a, 0xc5, + 0xc8, 0xb5, 0x67, 0xdc, 0x18, 0x5a, 0x75, 0x6e, + 0x97, 0xc9, 0x82, 0x16, 0x4f, 0xe2, 0x58, 0x59, + 0xe0, 0xd1, 0xdc, 0xc1, 0x47, 0x5c, 0x80, 0xa6, + 0x15, 0xb2, 0x12, 0x3a, 0xf1, 0xf5, 0xf9, 0x4c, + 0x11, 0xe3, 0xe9, 0x40, 0x2c, 0x3a, 0xc5, 0x58, + 0xf5, 0x00, 0x19, 0x9d, 0x95, 0xb6, 0xd3, 0xe3, + 0x01, 0x75, 0x85, 0x86, 0x28, 0x1d, 0xcd, 0x26, + }, + }, + { + .algorithm = NID_sha3_512, + .in = + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno" + "mnopnopq", + .in_len = 56, + .out = { + 0x04, 0xa3, 0x71, 0xe8, 0x4e, 0xcf, 0xb5, 0xb8, + 0xb7, 0x7c, 0xb4, 0x86, 0x10, 0xfc, 0xa8, 0x18, + 0x2d, 0xd4, 0x57, 0xce, 0x6f, 0x32, 0x6a, 0x0f, + 0xd3, 0xd7, 0xec, 0x2f, 0x1e, 0x91, 0x63, 0x6d, + 0xee, 0x69, 0x1f, 0xbe, 0x0c, 0x98, 0x53, 0x02, + 0xba, 0x1b, 0x0d, 0x8d, 0xc7, 0x8c, 0x08, 0x63, + 0x46, 0xb5, 0x33, 0xb4, 0x9c, 0x03, 0x0d, 0x99, + 0xa2, 0x7d, 0xaf, 0x11, 0x39, 0xd6, 0xe7, 0x5e, + }, + }, + { + .algorithm = NID_sha3_512, + .in = + "abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu", + .in_len = 112, + .out = { + 0xaf, 0xeb, 0xb2, 0xef, 0x54, 0x2e, 0x65, 0x79, + 0xc5, 0x0c, 0xad, 0x06, 0xd2, 0xe5, 0x78, 0xf9, + 0xf8, 0xdd, 0x68, 0x81, 0xd7, 0xdc, 0x82, 0x4d, + 0x26, 0x36, 0x0f, 0xee, 0xbf, 0x18, 0xa4, 0xfa, + 0x73, 0xe3, 0x26, 0x11, 0x22, 0x94, 0x8e, 0xfc, + 0xfd, 0x49, 0x2e, 0x74, 0xe8, 0x2e, 0x21, 0x89, + 0xed, 0x0f, 0xb4, 0x40, 0xd1, 0x87, 0xf3, 0x82, + 0x27, 0x0c, 0xb4, 0x55, 0xf2, 0x1d, 0xd1, 0x85, + }, }, }; @@ -322,7 +550,7 @@ static const struct sha_repetition_test sha_repetition_tests[] = { 0x34, 0xaa, 0x97, 0x3c, 0xd4, 0xc4, 0xda, 0xa4, 0xf6, 0x1e, 0xeb, 0x2b, 0xdb, 0xad, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6f, - } + }, }, /* SHA-224 */ @@ -335,7 +563,7 @@ static const struct sha_repetition_test sha_repetition_tests[] = { 0xbb, 0xb4, 0xc1, 0xea, 0x97, 0x61, 0x8a, 0x4b, 0xf0, 0x3f, 0x42, 0x58, 0x19, 0x48, 0xb2, 0xee, 0x4e, 0xe7, 0xad, 0x67, - } + }, }, /* SHA-256 */ @@ -348,7 +576,7 @@ static const struct sha_repetition_test sha_repetition_tests[] = { 0x81, 0xa1, 0xc7, 0xe2, 0x84, 0xd7, 0x3e, 0x67, 0xf1, 0x80, 0x9a, 0x48, 0xa4, 0x97, 0x20, 0x0e, 0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0, - } + }, }, /* SHA-384 */ @@ -363,7 +591,7 @@ static const struct sha_repetition_test sha_repetition_tests[] = { 0x79, 0x72, 0xce, 0xc5, 0x70, 0x4c, 0x2a, 0x5b, 0x07, 0xb8, 0xb3, 0xdc, 0x38, 0xec, 0xc4, 0xeb, 0xae, 0x97, 0xdd, 0xd8, 0x7f, 0x3d, 0x89, 0x85, - } + }, }, /* SHA-512 */ @@ -380,7 +608,65 @@ static const struct sha_repetition_test sha_repetition_tests[] = { 0x4c, 0xb0, 0x43, 0x2c, 0xe5, 0x77, 0xc3, 0x1b, 0xeb, 0x00, 0x9c, 0x5c, 0x2c, 0x49, 0xaa, 0x2e, 0x4e, 0xad, 0xb2, 0x17, 0xad, 0x8c, 0xc0, 0x9b, - } + }, + }, + + /* SHA3-224 */ + { + .algorithm = NID_sha3_224, + .in = 'a', + .in_repetitions = 1000000, + .out = { + 0xd6, 0x93, 0x35, 0xb9, 0x33, 0x25, 0x19, 0x2e, + 0x51, 0x6a, 0x91, 0x2e, 0x6d, 0x19, 0xa1, 0x5c, + 0xb5, 0x1c, 0x6e, 0xd5, 0xc1, 0x52, 0x43, 0xe7, + 0xa7, 0xfd, 0x65, 0x3c, + }, + }, + + /* SHA3-256 */ + { + .algorithm = NID_sha3_256, + .in = 'a', + .in_repetitions = 1000000, + .out = { + 0x5c, 0x88, 0x75, 0xae, 0x47, 0x4a, 0x36, 0x34, + 0xba, 0x4f, 0xd5, 0x5e, 0xc8, 0x5b, 0xff, 0xd6, + 0x61, 0xf3, 0x2a, 0xca, 0x75, 0xc6, 0xd6, 0x99, + 0xd0, 0xcd, 0xcb, 0x6c, 0x11, 0x58, 0x91, 0xc1, + }, + }, + + /* SHA3-384 */ + { + .algorithm = NID_sha3_384, + .in = 'a', + .in_repetitions = 1000000, + .out = { + 0xee, 0xe9, 0xe2, 0x4d, 0x78, 0xc1, 0x85, 0x53, + 0x37, 0x98, 0x34, 0x51, 0xdf, 0x97, 0xc8, 0xad, + 0x9e, 0xed, 0xf2, 0x56, 0xc6, 0x33, 0x4f, 0x8e, + 0x94, 0x8d, 0x25, 0x2d, 0x5e, 0x0e, 0x76, 0x84, + 0x7a, 0xa0, 0x77, 0x4d, 0xdb, 0x90, 0xa8, 0x42, + 0x19, 0x0d, 0x2c, 0x55, 0x8b, 0x4b, 0x83, 0x40, + }, + }, + + /* SHA3-512 */ + { + .algorithm = NID_sha3_512, + .in = 'a', + .in_repetitions = 1000000, + .out = { + 0x3c, 0x3a, 0x87, 0x6d, 0xa1, 0x40, 0x34, 0xab, + 0x60, 0x62, 0x7c, 0x07, 0x7b, 0xb9, 0x8f, 0x7e, + 0x12, 0x0a, 0x2a, 0x53, 0x70, 0x21, 0x2d, 0xff, + 0xb3, 0x38, 0x5a, 0x18, 0xd4, 0xf3, 0x88, 0x59, + 0xed, 0x31, 0x1d, 0x0a, 0x9d, 0x51, 0x41, 0xce, + 0x9c, 0xc5, 0xc6, 0x6e, 0xe6, 0x89, 0xb2, 0x66, + 0xa8, 0xaa, 0x18, 0xac, 0xe8, 0x28, 0x2a, 0x0e, + 0x0d, 0xb5, 0x96, 0xc9, 0x0b, 0x0a, 0x7b, 0x87, + }, }, }; @@ -430,6 +716,30 @@ sha_hash_from_algorithm(int algorithm, const char **out_label, md = EVP_sha512(); len = SHA512_DIGEST_LENGTH; break; + case NID_sha3_224: + label = SN_sha3_224; + sha_func = NULL; + md = EVP_sha3_224(); + len = 224 / 8; + break; + case NID_sha3_256: + label = SN_sha3_256; + sha_func = NULL; + md = EVP_sha3_256(); + len = 256 / 8; + break; + case NID_sha3_384: + label = SN_sha3_384; + sha_func = NULL; + md = EVP_sha3_384(); + len = 384 / 8; + break; + case NID_sha3_512: + label = SN_sha3_512; + sha_func = NULL; + md = EVP_sha3_512(); + len = 512 / 8; + break; default: fprintf(stderr, "FAIL: unknown algorithm (%d)\n", algorithm); @@ -473,60 +783,66 @@ sha_test(void) goto failed; /* Digest */ - memset(out, 0, sizeof(out)); - sha_func(st->in, st->in_len, out); - if (memcmp(st->out, out, out_len) != 0) { - fprintf(stderr, "FAIL (%s): mismatch\n", label); - goto failed; + if (sha_func != NULL) { + memset(out, 0, sizeof(out)); + sha_func(st->in, st->in_len, out); + if (memcmp(st->out, out, out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): mismatch\n", + label, i); + goto failed; + } } /* EVP single-shot digest */ memset(out, 0, sizeof(out)); if (!EVP_Digest(st->in, st->in_len, out, NULL, md, NULL)) { - fprintf(stderr, "FAIL (%s): EVP_Digest failed\n", - label); + fprintf(stderr, "FAIL (%s:%zu): EVP_Digest failed\n", + label, i); goto failed; } if (memcmp(st->out, out, out_len) != 0) { - fprintf(stderr, "FAIL (%s): EVP single-shot mismatch\n", - label); + fprintf(stderr, + "FAIL (%s:%zu): EVP single-shot mismatch\n", + label, i); goto failed; } /* EVP digest */ memset(out, 0, sizeof(out)); if (!EVP_DigestInit_ex(hash, md, NULL)) { - fprintf(stderr, "FAIL (%s): EVP_DigestInit_ex failed\n", - label); + fprintf(stderr, + "FAIL (%s:%zu): EVP_DigestInit_ex failed\n", + label, i); goto failed; } in_len = st->in_len / 2; if (!EVP_DigestUpdate(hash, st->in, in_len)) { fprintf(stderr, - "FAIL (%s): EVP_DigestUpdate first half failed\n", - label); + "FAIL (%s:%zu): EVP_DigestUpdate first half " + "failed\n", label, i); goto failed; } if (!EVP_DigestUpdate(hash, st->in + in_len, st->in_len - in_len)) { fprintf(stderr, - "FAIL (%s): EVP_DigestUpdate second half failed\n", - label); + "FAIL (%s:%zu): EVP_DigestUpdate second half " + "failed\n", label, i); goto failed; } if (!EVP_DigestFinal_ex(hash, out, NULL)) { fprintf(stderr, - "FAIL (%s): EVP_DigestFinal_ex failed\n", - label); + "FAIL (%s:%zu): EVP_DigestFinal_ex failed\n", + label, i); goto failed; } if (memcmp(st->out, out, out_len) != 0) { - fprintf(stderr, "FAIL (%s): EVP mismatch\n", label); + fprintf(stderr, "FAIL (%s:%zu): EVP mismatch\n", + label, i); goto failed; } } @@ -565,8 +881,8 @@ sha_repetition_test(void) /* EVP digest */ if (!EVP_DigestInit_ex(hash, md, NULL)) { fprintf(stderr, - "FAIL (%s): EVP_DigestInit_ex failed\n", - label); + "FAIL (%s:%zu): EVP_DigestInit_ex failed\n", + label, i); goto failed; } @@ -579,8 +895,8 @@ sha_repetition_test(void) if (!EVP_DigestUpdate(hash, buf, part_len)) { fprintf(stderr, - "FAIL (%s): EVP_DigestUpdate failed\n", - label); + "FAIL (%s:%zu): EVP_DigestUpdate failed\n", + label, i); goto failed; } @@ -589,13 +905,14 @@ sha_repetition_test(void) if (!EVP_DigestFinal_ex(hash, out, NULL)) { fprintf(stderr, - "FAIL (%s): EVP_DigestFinal_ex failed\n", - label); + "FAIL (%s:%zu): EVP_DigestFinal_ex failed\n", + label, i); goto failed; } if (memcmp(st->out, out, out_len) != 0) { - fprintf(stderr, "FAIL (%s): EVP mismatch\n", label); + fprintf(stderr, "FAIL (%s:%zu): EVP mismatch\n", + label, i); goto failed; } } diff --git a/regress/lib/libssl/Makefile b/regress/lib/libssl/Makefile index f9919404f..35323e2c4 100644 --- a/regress/lib/libssl/Makefile +++ b/regress/lib/libssl/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.52 2023/07/02 17:21:32 beck Exp $ +# $OpenBSD: Makefile,v 1.54 2023/07/15 19:32:54 tb Exp $ SUBDIR += api SUBDIR += asn1 SUBDIR += buffer SUBDIR += bytestring SUBDIR += ciphers -#SUBDIR += client +SUBDIR += client SUBDIR += dtls SUBDIR += exporter SUBDIR += handshake @@ -13,8 +13,9 @@ SUBDIR += pqueue SUBDIR += quic SUBDIR += record SUBDIR += record_layer -#SUBDIR += server +SUBDIR += server SUBDIR += ssl +SUBDIR += symbols SUBDIR += tls SUBDIR += tlsext SUBDIR += tlslegacy diff --git a/regress/lib/libssl/client/clienttest.c b/regress/lib/libssl/client/clienttest.c index 8ecc54467..8fb5a1da7 100644 --- a/regress/lib/libssl/client/clienttest.c +++ b/regress/lib/libssl/client/clienttest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clienttest.c,v 1.40 2023/04/23 18:59:41 tb Exp $ */ +/* $OpenBSD: clienttest.c,v 1.42 2023/07/11 17:03:44 tb Exp $ */ /* * Copyright (c) 2015 Joel Sing * @@ -36,7 +36,7 @@ #define TLS13_RANDOM_OFFSET (TLS13_HM_OFFSET + 2) #define TLS13_SESSION_OFFSET (TLS13_HM_OFFSET + 34) #define TLS13_CIPHER_OFFSET (TLS13_HM_OFFSET + 69) -#define TLS13_KEY_SHARE_OFFSET (TLS13_HM_OFFSET + 192) +#define TLS13_KEY_SHARE_OFFSET (TLS13_HM_OFFSET + 188) #define TLS13_ONLY_KEY_SHARE_OFFSET (TLS13_HM_OFFSET + 98) #define TLS1_3_VERSION_ONLY (TLS1_3_VERSION | 0x10000) @@ -213,7 +213,7 @@ static const uint8_t cipher_list_tls12_chacha[] = { }; static const uint8_t client_hello_tls12[] = { - 0x16, 0x03, 0x01, 0x00, 0xbb, 0x01, 0x00, 0x00, + 0x16, 0x03, 0x03, 0x00, 0xbb, 0x01, 0x00, 0x00, 0xb7, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -270,8 +270,8 @@ static const uint8_t cipher_list_tls13_chacha[] = { }; static const uint8_t client_hello_tls13[] = { - 0x16, 0x03, 0x01, 0x01, 0x18, 0x01, 0x00, 0x01, - 0x14, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x16, 0x03, 0x03, 0x01, 0x14, 0x01, 0x00, 0x01, + 0x10, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -292,20 +292,20 @@ static const uint8_t client_hello_tls13[] = { 0x00, 0x2f, 0x00, 0xba, 0x00, 0x41, 0xc0, 0x11, 0xc0, 0x07, 0x00, 0x05, 0xc0, 0x12, 0xc0, 0x08, 0x00, 0x16, 0x00, 0x0a, 0x00, 0xff, 0x01, 0x00, - 0x00, 0x6b, 0x00, 0x2b, 0x00, 0x09, 0x08, 0x03, - 0x04, 0x03, 0x03, 0x03, 0x02, 0x03, 0x01, 0x00, - 0x33, 0x00, 0x26, 0x00, 0x24, 0x00, 0x1d, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x67, 0x00, 0x2b, 0x00, 0x05, 0x04, 0x03, + 0x04, 0x03, 0x03, 0x00, 0x33, 0x00, 0x26, 0x00, + 0x24, 0x00, 0x1d, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, - 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x1d, 0x00, - 0x17, 0x00, 0x18, 0x00, 0x19, 0x00, 0x23, 0x00, - 0x00, 0x00, 0x0d, 0x00, 0x18, 0x00, 0x16, 0x08, - 0x06, 0x06, 0x01, 0x06, 0x03, 0x08, 0x05, 0x05, - 0x01, 0x05, 0x03, 0x08, 0x04, 0x04, 0x01, 0x04, - 0x03, 0x02, 0x01, 0x02, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, + 0x02, 0x01, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, + 0x08, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x00, + 0x19, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0d, 0x00, + 0x18, 0x00, 0x16, 0x08, 0x06, 0x06, 0x01, 0x06, + 0x03, 0x08, 0x05, 0x05, 0x01, 0x05, 0x03, 0x08, + 0x04, 0x04, 0x01, 0x04, 0x03, 0x02, 0x01, 0x02, + 0x03, }; static const uint8_t cipher_list_tls13_only_aes[] = { @@ -351,6 +351,7 @@ struct client_hello_test { const size_t key_share_start; const SSL_METHOD *(*ssl_method)(void); const long ssl_options; + int connect_fails; }; static const struct client_hello_test client_hello_tests[] = { @@ -359,6 +360,7 @@ static const struct client_hello_test client_hello_tests[] = { .protocol = DTLS1_VERSION, .random_start = DTLS_RANDOM_OFFSET, .ssl_method = DTLSv1_client_method, + .connect_fails = 1, }, { .desc = "DTLSv1.2 client method", @@ -378,6 +380,7 @@ static const struct client_hello_test client_hello_tests[] = { .random_start = DTLS_RANDOM_OFFSET, .ssl_method = DTLS_client_method, .ssl_options = SSL_OP_NO_DTLSv1_2, + .connect_fails = 1, }, { .desc = "DTLS client method (no DTLSv1.0)", @@ -391,12 +394,14 @@ static const struct client_hello_test client_hello_tests[] = { .protocol = TLS1_VERSION, .random_start = SSL3_RANDOM_OFFSET, .ssl_method = TLSv1_client_method, + .connect_fails = 1, }, { .desc = "TLSv1_1 client method", .protocol = TLS1_1_VERSION, .random_start = SSL3_RANDOM_OFFSET, .ssl_method = TLSv1_1_client_method, + .connect_fails = 1, }, { .desc = "TLSv1_2 client method", @@ -422,15 +427,19 @@ static const struct client_hello_test client_hello_tests[] = { }, { .desc = "SSLv23 (no TLSv1.2)", - .protocol = TLS1_1_VERSION, - .random_start = SSL3_RANDOM_OFFSET, + .protocol = TLS1_3_VERSION_ONLY, + .random_start = TLS13_RANDOM_OFFSET, + .session_start = TLS13_SESSION_OFFSET, + .key_share_start = TLS13_ONLY_KEY_SHARE_OFFSET, .ssl_method = SSLv23_client_method, .ssl_options = SSL_OP_NO_TLSv1_2, }, { .desc = "SSLv23 (no TLSv1.1)", - .protocol = TLS1_VERSION, - .random_start = SSL3_RANDOM_OFFSET, + .protocol = TLS1_3_VERSION, + .random_start = TLS13_RANDOM_OFFSET, + .session_start = TLS13_SESSION_OFFSET, + .key_share_start = TLS13_KEY_SHARE_OFFSET, .ssl_method = SSLv23_client_method, .ssl_options = SSL_OP_NO_TLSv1_1, }, @@ -452,15 +461,19 @@ static const struct client_hello_test client_hello_tests[] = { }, { .desc = "TLS (no TLSv1.2)", - .protocol = TLS1_1_VERSION, - .random_start = SSL3_RANDOM_OFFSET, + .protocol = TLS1_3_VERSION_ONLY, + .random_start = TLS13_RANDOM_OFFSET, + .session_start = TLS13_SESSION_OFFSET, + .key_share_start = TLS13_ONLY_KEY_SHARE_OFFSET, .ssl_method = TLS_client_method, .ssl_options = SSL_OP_NO_TLSv1_2, }, { .desc = "TLS (no TLSv1.1)", - .protocol = TLS1_VERSION, - .random_start = SSL3_RANDOM_OFFSET, + .protocol = TLS1_3_VERSION, + .random_start = TLS13_RANDOM_OFFSET, + .session_start = TLS13_SESSION_OFFSET, + .key_share_start = TLS13_KEY_SHARE_OFFSET, .ssl_method = TLS_client_method, .ssl_options = SSL_OP_NO_TLSv1_1, }, @@ -661,6 +674,8 @@ client_hello_test(int testno, const struct client_hello_test *cht) SSL_set_bio(ssl, rbio, wbio); if (SSL_connect(ssl) != 0) { + if (cht->connect_fails) + goto done; fprintf(stderr, "SSL_connect() returned non-zero\n"); goto failure; } @@ -709,6 +724,7 @@ client_hello_test(int testno, const struct client_hello_test *cht) goto failure; } + done: ret = 0; failure: diff --git a/regress/lib/libssl/server/servertest.c b/regress/lib/libssl/server/servertest.c index 3367836db..d572d1452 100644 --- a/regress/lib/libssl/server/servertest.c +++ b/regress/lib/libssl/server/servertest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: servertest.c,v 1.7 2022/06/10 22:00:15 tb Exp $ */ +/* $OpenBSD: servertest.c,v 1.9 2023/07/11 11:52:35 tb Exp $ */ /* * Copyright (c) 2015, 2016, 2017 Joel Sing * @@ -84,6 +84,7 @@ struct server_hello_test { const SSL_METHOD *(*ssl_method)(void); const long ssl_clear_options; const long ssl_set_options; + int accept_fails; }; static struct server_hello_test server_hello_tests[] = { @@ -94,6 +95,7 @@ static struct server_hello_test server_hello_tests[] = { .ssl_method = tls_legacy_method, .ssl_clear_options = SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1, .ssl_set_options = 0, + .accept_fails = 1, }, { .desc = "TLSv1.2 in SSLv2 record", @@ -102,6 +104,7 @@ static struct server_hello_test server_hello_tests[] = { .ssl_method = tls_legacy_method, .ssl_clear_options = SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1, .ssl_set_options = 0, + .accept_fails = 1, }, }; @@ -160,11 +163,14 @@ server_hello_test(int testno, struct server_hello_test *sht) SSL_set_bio(ssl, rbio, wbio); if (SSL_accept(ssl) != 0) { + if (sht->accept_fails) + goto done; fprintf(stderr, "SSL_accept() returned non-zero\n"); ERR_print_errors_fp(stderr); goto failure; } + done: ret = 0; failure: diff --git a/regress/lib/libssl/symbols/Makefile b/regress/lib/libssl/symbols/Makefile new file mode 100644 index 000000000..d500dfcd0 --- /dev/null +++ b/regress/lib/libssl/symbols/Makefile @@ -0,0 +1,22 @@ +# $OpenBSD: Makefile,v 1.2 2023/07/15 23:40:46 tb Exp $ + +PROG = symbols + +.include + +DPADD= ${LIBCRYPTO} ${LIBSSL} +LDFLAGS+= -lcrypto -lssl +LDFLAGS+= -Wl,--no-allow-shlib-undefined +CFLAGS+= -Wno-deprecated-declarations + +CLEANFILES+= symbols.c symbols.c.tmp + +symbols.c: symbols.awk ../../../../lib/libssl/Symbols.list + awk -f ${.CURDIR}/symbols.awk \ + < ${BSDSRCDIR}/lib/libssl/Symbols.list > $@.tmp && \ + mv -f $@.tmp $@ + +run-regress-symbols: symbols + ./symbols 2>/dev/null + +.include diff --git a/regress/lib/libssl/symbols/symbols.awk b/regress/lib/libssl/symbols/symbols.awk new file mode 100644 index 000000000..a847ade6d --- /dev/null +++ b/regress/lib/libssl/symbols/symbols.awk @@ -0,0 +1,65 @@ +# $OpenBSD: symbols.awk,v 1.2 2023/07/19 21:01:29 tb Exp $ + +# Copyright (c) 2018,2020,2023 Theo Buehler +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# usage: awk -f symbols.awk < Symbols.list > symbols.c + +BEGIN { + printf("#include \n\n") + + printf("#include \n") + printf("#include \n") + printf("#include \n") + printf("#include \n") + printf("#include \n") + printf("#include \n\n") + + printf("#include \n\n") # depends on ssl.h +} + +/^SSL_version_str$/ { + printf("extern const char *%s;\n", $0) +} + +{ + symbols[$0] = $0 + + # Undefine aliases, so we don't accidentally leave them in Symbols.list. + printf("#ifdef %s\n#undef %s\n#endif\n", $0, $0) +} + +END { + printf("\nint\nmain(void)\n{\n") + printf("\tsize_t i;\n"); + + printf("\tstruct {\n") + printf("\t\tconst char *const name;\n") + printf("\t\tconst void *addr;\n") + printf("\t} symbols[] = {\n") + + for (symbol in symbols) { + printf("\t\t{\n") + printf("\t\t\t.name = \"%s\",\n", symbol) + printf("\t\t\t.addr = &%s,\n", symbol) + printf("\t\t},\n") + } + + printf("\t\};\n\n") + + printf("\tfor (i = 0; i < sizeof(symbols) / sizeof(symbols[0]); i++)\n") + printf("\t\tfprintf(stderr, \"%%s: %%p\\n\", symbols[i].name, symbols[i].addr);\n") + printf("\n\tprintf(\"OK\\n\");\n") + printf("\n\treturn 0;\n}\n") +} diff --git a/regress/sys/net/pf_trans/Makefile b/regress/sys/net/pf_trans/Makefile index 9bcbc0214..bc38214a6 100644 --- a/regress/sys/net/pf_trans/Makefile +++ b/regress/sys/net/pf_trans/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.1 2023/07/06 19:55:57 sashan Exp $ +# $OpenBSD: Makefile,v 1.2 2023/07/10 17:46:03 anton Exp $ PROGS+= dev-limit PROGS+= iocmd-limit @@ -8,6 +8,7 @@ CFLAGS+= -Wall REGRESS_ROOT_TARGETS= run-regress-dev-limit \ run-regress-iocmd-limit +TIMEOUT?= 10 # # Create 2048 processes. Each child process will attempt @@ -16,7 +17,7 @@ REGRESS_ROOT_TARGETS= run-regress-dev-limit \ # There should be 1023 children, which could open /dev/pf. # run-regress-dev-limit: - ${SUDO} ./dev-limit -c 2048 -s 1023 -t 10 + ${SUDO} ./dev-limit -c 2048 -s 1023 -t ${TIMEOUT} # # Open 1024 tickets for DIOCGETRULES without closing them. diff --git a/regress/sys/net/pf_trans/dev-limit.c b/regress/sys/net/pf_trans/dev-limit.c index b766a1e5a..5a0aa85cd 100644 --- a/regress/sys/net/pf_trans/dev-limit.c +++ b/regress/sys/net/pf_trans/dev-limit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev-limit.c,v 1.1 2023/07/06 19:55:58 sashan Exp $ */ +/* $OpenBSD: dev-limit.c,v 1.3 2023/07/12 18:21:39 anton Exp $ */ /* * Copyright (c) 2023 Alexandr Nedvedicky @@ -114,11 +114,17 @@ main(int argc, char *const argv[]) signal(SIGCHLD, handle_sigchild); pids = (pid_t *)malloc(sizeof(pid_t) * chld_count); if (pids == 0) - err(1, "%s malloc: ", argv[0]); + err(1, NULL); i = 0; while ((sigchild == 0) && (i < chld_count)) { - if ((pids[i++] = fork()) == 0) + pid_t pid; + + pid = fork(); + pids[i++] = pid; + if (pid == -1) + warn("fork"); + else if (pid == 0) execl(argv[0], argv[0], "-t", sleep_arg, NULL); } chld_count = i; diff --git a/regress/sys/net/pf_trans/iocmd-limit.c b/regress/sys/net/pf_trans/iocmd-limit.c index 53d197a54..f847abd2a 100644 --- a/regress/sys/net/pf_trans/iocmd-limit.c +++ b/regress/sys/net/pf_trans/iocmd-limit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iocmd-limit.c,v 1.1 2023/07/06 19:55:58 sashan Exp $ */ +/* $OpenBSD: iocmd-limit.c,v 1.2 2023/07/10 17:45:17 anton Exp $ */ /* * Copyright (c) 2023 Alexandr Nedvedicky @@ -65,7 +65,7 @@ do_DIOCGETRULES_test(int dev) * exit right away. */ if (errno != EBUSY) - err(1, "%s DIOCGETRULES: ", __func__); + err(1, "%s DIOCGETRULES", __func__); } return (rv); @@ -100,9 +100,9 @@ do_DIOCXEND_test(int dev) pr.rule.action = PF_PASS; if ((rv = ioctl(dev, DIOCGETRULES, &pr)) == -1) - warn("%s DIOCGETRULES: ", __func__); + warn("%s DIOCGETRULES", __func__); else if ((rv = ioctl(dev, DIOCXEND, &pr.ticket)) == -1) - warn("%s DIOCXEND: ", __func__); + warn("%s DIOCXEND", __func__); return (rv); } @@ -190,7 +190,7 @@ main(int argc, char *const argv[]) dev = open("/dev/pf", O_RDONLY); if (dev < 0) - err(1, "open(\"dev/pf\"): "); + err(1, "open(\"dev/pf\")"); while (i < iterations) { if (test_iocmd->iocmd_test(dev) != 0) diff --git a/regress/sys/net/rdomains/lo.ok b/regress/sys/net/rdomains/lo.ok index 4c88acccd..c9d3e8597 100644 --- a/regress/sys/net/rdomains/lo.ok +++ b/regress/sys/net/rdomains/lo.ok @@ -1 +1 @@ -loRDO: flags=8049 rdomain RDO mtu 32768 +loRDO: flags=2008049 rdomain RDO mtu 32768 diff --git a/regress/usr.bin/rsync/Makefile b/regress/usr.bin/rsync/Makefile index dcf3d026c..3be5644e7 100644 --- a/regress/usr.bin/rsync/Makefile +++ b/regress/usr.bin/rsync/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 2023/04/29 00:20:46 bluhm Exp $ +# $OpenBSD: Makefile,v 1.4 2023/07/16 06:36:18 anton Exp $ # evaluate once in main make invocation, then get list of test from environment .if ! (make(clean) || make(cleandir) || make(obj)) @@ -13,27 +13,18 @@ clean: rm -rf dir* find* # some of these tests pass or fail unreliably -REGRESS_EXPECTED_FAILURES = run-openrsync-openrsync-test10_perms \ - run-openrsync-openrsync-test11_middlediff \ - run-openrsync-openrsync-test11b_middlediff \ - run-openrsync-openrsync-test3_minusexclude \ - run-openrsync-openrsync-test3b_minusexclude \ - run-openrsync-openrsync-test3c_minusexclude \ +REGRESS_EXPECTED_FAILURES = run-openrsync-openrsync-test3_minusexclude \ run-openrsync-openrsync-test6_perms \ run-openrsync-openrsync-test6b_perms \ run-openrsync-openrsync-test7_symlinks \ - run-openrsync-openrsync-test7b_symlinks \ - run-openrsync-openrsync-test9_norecurse \ - run-openrsync-rsync-test10_perms \ - run-openrsync-rsync-test11_middlediff \ - run-openrsync-rsync-test11b_middlediff \ + run-openrsync-openrsync-test10_perms \ + run-openrsync-openrsync-test13_perms \ run-openrsync-rsync-test3_minusexclude \ run-openrsync-rsync-test6_perms \ run-openrsync-rsync-test6b_perms \ run-openrsync-rsync-test7_symlinks \ - run-rsync-openrsync-test12_inex \ - run-openrsync-rsync-test12c_inex \ - run-rsync-rsync-test3c_minusexclude + run-openrsync-rsync-test10_perms \ + run-openrsync-rsync-test13_perms .if ! exists(${RSYNC_PORT}) .for t in ${RSYNC_TESTS} diff --git a/regress/usr.bin/rsync/lib.sh b/regress/usr.bin/rsync/lib.sh index 37732b686..3ed63c8a8 100644 --- a/regress/usr.bin/rsync/lib.sh +++ b/regress/usr.bin/rsync/lib.sh @@ -65,9 +65,14 @@ findme () fi ( cd "$1" ; shift - # Cut out the inode number and blocks used. - # Maybe later also cut out size in bytes for directories. - find "$@" -ls | sed 's/^ *[0-9]* *[0-9]* *//' | sort + # Remove unstable fields: + # 1: inode + # 2: size in blocks + # 8-10: last modification time + find "$@" -ls | + sed -e 's/^[[:space:]]*//' -e 's/[[:space:]][[:space:]]*/ /g' | + cut -d ' ' -f 3-7,11- | + sort ) } diff --git a/regress/usr.bin/rsync/test10_perms.test b/regress/usr.bin/rsync/test10_perms.test index e7570f19e..fea71d739 100644 --- a/regress/usr.bin/rsync/test10_perms.test +++ b/regress/usr.bin/rsync/test10_perms.test @@ -10,6 +10,7 @@ mkdir dir1 cd dir1 generate_tree_1 chmod 640 foo/bar/baz/one.txt +touch -m -t 199901020405 foo/bar/baz/one.txt # make the tree we want to compare to mkdir ../dir2 cd ../dir2 diff --git a/regress/usr.bin/rsync/test13_perms.test b/regress/usr.bin/rsync/test13_perms.test new file mode 100644 index 000000000..79a010367 --- /dev/null +++ b/regress/usr.bin/rsync/test13_perms.test @@ -0,0 +1,23 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +generate_tree() { + mkdirfile "${1}/one.txt" +} + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +generate_tree dir1 +# make the tree we want to compare to +generate_tree dir2 + +# Also make the target tree and mess up some permissions in there. +# We expect rsync to reset this to what dir1 has. +generate_tree dir3 +chmod 070 dir3/one.txt +touch -m -t 199901020405 dir3/one.txt + +$rsync -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test6_perms.test b/regress/usr.bin/rsync/test6_perms.test index 4c619fe6d..36f930b1e 100644 --- a/regress/usr.bin/rsync/test6_perms.test +++ b/regress/usr.bin/rsync/test6_perms.test @@ -19,7 +19,9 @@ mkdir ../dir3 cd ../dir3 generate_tree_1 chmod 600 foo/bar/baz/one.txt +touch -m -t 199901020405 foo/bar/baz/one.txt chmod 070 foo/bar/baz/one2.txt +touch -m -t 199901020405 foo/bar/baz/one2.txt cd .. $rsync -a dir1/ dir3 diff --git a/regress/usr.bin/rsync/test6b_perms.test b/regress/usr.bin/rsync/test6b_perms.test index 9a23281ad..bfaac6e29 100644 --- a/regress/usr.bin/rsync/test6b_perms.test +++ b/regress/usr.bin/rsync/test6b_perms.test @@ -18,13 +18,17 @@ mkdir ../dir2 cd ../dir2 generate_tree_1 chmod 600 foo/bar/baz/one.txt +touch -m -t 199901020405 foo/bar/baz/one.txt chmod 777 foo/bar/baz/one2.txt +touch -m -t 199901020405 foo/bar/baz/one2.txt mkdir ../dir3 cd ../dir3 generate_tree_1 chmod 600 foo/bar/baz/one.txt +touch -m -t 199901020405 foo/bar/baz/one.txt chmod 777 foo/bar/baz/one2.txt +touch -m -t 199901020405 foo/bar/baz/one2.txt cd .. # call -a without -p. diff --git a/regress/usr.sbin/bgpd/integrationtests/Makefile b/regress/usr.sbin/bgpd/integrationtests/Makefile index 035e1850f..31f32c8df 100644 --- a/regress/usr.sbin/bgpd/integrationtests/Makefile +++ b/regress/usr.sbin/bgpd/integrationtests/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.20 2022/11/09 14:31:31 claudio Exp $ +# $OpenBSD: Makefile,v 1.21 2023/07/12 15:34:59 claudio Exp $ REGRESS_TARGETS = network_statement md5 ovs mrt pftable \ maxprefix maxprefixout maxcomm \ - as0 med eval_all policy l3vpn + as0 med eval_all policy l3vpn attr BGPD ?= /usr/sbin/bgpd @@ -53,6 +53,11 @@ med: eval_all: # install exabgp from ports for additional tests @echo SKIPPED + +attr: + # install exabgp from ports for additional tests + @echo SKIPPED + .else .SUFFIXES: .conf .in @@ -70,6 +75,9 @@ med: api-exabgp exabgp.med.conf eval_all: api-exabgp exabgp.eval_all.conf ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12 +attr: api-exabgp exabgp.attr.conf + ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12 + .endif .include diff --git a/regress/usr.sbin/bgpd/integrationtests/attr.sh b/regress/usr.sbin/bgpd/integrationtests/attr.sh new file mode 100644 index 000000000..6147eaa05 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/attr.sh @@ -0,0 +1,105 @@ +#!/bin/ksh +# $OpenBSD: attr.sh,v 1.1 2023/07/12 15:34:59 claudio Exp $ + +set -e + +BGPD=$1 +BGPDCONFIGDIR=$2 +RDOMAIN1=$3 +RDOMAIN2=$4 +PAIR1=$5 +PAIR2=$6 + +RDOMAINS="${RDOMAIN1} ${RDOMAIN2}" +PAIRS="${PAIR1} ${PAIR2}" +PAIR1IP=10.12.57.1 +PAIR2IP=10.12.57.2 +PAIR2IP2=10.12.57.3 +PAIR2IP3=10.12.57.4 + +error_notify() { + echo cleanup + pkill -T ${RDOMAIN1} bgpd || true + pkill -T ${RDOMAIN2} -f exabgp || true + sleep 1 + ifconfig ${PAIR2} destroy || true + ifconfig ${PAIR1} destroy || true + route -qn -T ${RDOMAIN1} flush || true + route -qn -T ${RDOMAIN2} flush || true + ifconfig lo${RDOMAIN1} destroy || true + ifconfig lo${RDOMAIN2} destroy || true + if [ $1 -ne 0 ]; then + echo FAILED + exit 1 + else + echo SUCCESS + fi +} + +run_exabgp() { + local _t=$1 + + shift + env exabgp.log.destination=stdout \ + exabgp.log.packets=true \ + exabgp.log.parser=true \ + exabgp.log.level=DEBUG \ + exabgp.api.cli=false \ + exabgp.daemon.user=build \ + route -T ${RDOMAIN2} exec exabgp -1 ${1+"$@"} > ./exabgp.$_t.log +} + +if [ ! -x /usr/local/bin/exabgp ]; then + echo install exabgp from ports for this test >&2 + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo need root privileges >&2 + exit 1 +fi + +trap 'error_notify $?' EXIT + +echo check if rdomains are busy +for n in ${RDOMAINS}; do + if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then + echo routing domain ${n} is already used >&2 + exit 1 + fi +done + +echo check if interfaces are busy +for n in ${PAIRS}; do + /sbin/ifconfig "${n}" >/dev/null 2>&1 && \ + ( echo interface ${n} is already used >&2; exit 1 ) +done + +set -x + +echo setup +ifconfig ${PAIR1} rdomain ${RDOMAIN1} ${PAIR1IP}/29 up +ifconfig ${PAIR2} rdomain ${RDOMAIN2} ${PAIR2IP}/29 up +ifconfig ${PAIR2} alias ${PAIR2IP2}/32 +ifconfig ${PAIR2} alias ${PAIR2IP3}/32 +ifconfig ${PAIR1} patch ${PAIR2} +ifconfig lo${RDOMAIN1} inet 127.0.0.1/8 +ifconfig lo${RDOMAIN2} inet 127.0.0.1/8 +[ -p attr.fifo ] || mkfifo attr.fifo + +echo run bgpd +route -T ${RDOMAIN1} exec ${BGPD} \ + -v -f ${BGPDCONFIGDIR}/bgpd.attr.conf + +sleep 1 + +echo test2 +run_exabgp attr exabgp.attr.conf > exabgp.attr.out 2>&1 & + +sleep 3 +route -T ${RDOMAIN1} exec bgpctl sh rib in | tee attr.out +sleep .2 +diff -u ${BGPDCONFIGDIR}/exabgp.attr.ok attr.out +echo OK + +exit 0 diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.attr.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.attr.conf new file mode 100644 index 000000000..7678397a2 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.attr.conf @@ -0,0 +1,8 @@ +AS 64500 +router-id 10.12.57.1 +fib-update no + +neighbor 10.12.57.0/29 + +allow from any +allow to any diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.attr.in b/regress/usr.sbin/bgpd/integrationtests/exabgp.attr.in new file mode 100644 index 000000000..14e173683 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.attr.in @@ -0,0 +1,60 @@ +process reader { + run "##OBJDIR##/api-exabgp" -t 10 "##OBJDIR##/attr.fifo"; + encoder text; +} + +neighbor 10.12.57.1 { + router-id 10.12.57.2; + local-address 10.12.57.2; + local-as 64501; + peer-as 64500; + group-updates; + adj-rib-in false; + passive false; + + family { + ipv4 unicast; + } + + api { + processes [ reader ]; + neighbor-changes; + receive { + parsed; + update; + notification; + } + } +} + +neighbor 10.12.57.1 { + router-id 10.12.57.3; + local-address 10.12.57.3; + local-as 64502; + peer-as 64500; + group-updates; + adj-rib-in false; + passive false; + + family { + ipv4 unicast; + } + + static { + route 10.12.0.0/24 next-hop self; + # aggregator + route 10.12.1.0/24 next-hop self attribute [ 0x07 0xc0 0x02 ]; + # communities + route 10.12.2.0/24 next-hop self attribute [ 0x08 0xc0 0x02 ]; + # ext communities + route 10.12.3.0/24 next-hop self attribute [ 0x10 0xc0 0x02 ]; + # as4-path + route 10.12.4.0/24 next-hop self attribute [ 0x11 0xc0 0x02 ]; + # as4-aggregator + route 10.12.5.0/24 next-hop self attribute [ 0x12 0xc0 0x02 ]; + # large communities + route 10.12.6.0/24 next-hop self attribute [ 0x20 0xc0 0x02 ]; + # OTC + route 10.12.7.0/24 next-hop self attribute [ 0x23 0xc0 0x02 ]; + } +} diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.attr.ok b/regress/usr.sbin/bgpd/integrationtests/exabgp.attr.ok new file mode 100644 index 000000000..d1097d623 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.attr.ok @@ -0,0 +1,15 @@ +flags: * = Valid, > = Selected, I = via IBGP, A = Announced, + S = Stale, E = Error +origin validation state: N = not-found, V = valid, ! = invalid +aspa validation state: ? = unknown, V = valid, ! = invalid +origin: i = IGP, e = EGP, ? = Incomplete + +flags vs destination gateway lpref med aspath origin + N-? 10.12.0.0/24 10.12.57.3 100 0 64502 i + N-? 10.12.1.0/24 10.12.57.3 100 0 64502 i +E N-? 10.12.2.0/24 10.12.57.3 100 0 64502 i +E N-? 10.12.3.0/24 10.12.57.3 100 0 64502 i + N-? 10.12.4.0/24 10.12.57.3 100 0 64502 i + N-? 10.12.5.0/24 10.12.57.3 100 0 64502 i +E N-? 10.12.6.0/24 10.12.57.3 100 0 64502 i +E N-? 10.12.7.0/24 10.12.57.3 100 0 64502 i diff --git a/regress/usr.sbin/bgpd/unittests/rde_community_test.c b/regress/usr.sbin/bgpd/unittests/rde_community_test.c index 4b4457158..31df805e0 100644 --- a/regress/usr.sbin/bgpd/unittests/rde_community_test.c +++ b/regress/usr.sbin/bgpd/unittests/rde_community_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_community_test.c,v 1.7 2023/06/17 08:01:22 claudio Exp $ */ +/* $OpenBSD: rde_community_test.c,v 1.8 2023/07/12 15:27:11 claudio Exp $ */ /* * Copyright (c) 2019 Claudio Jeker @@ -46,6 +46,7 @@ static int test_parsing(size_t num, uint8_t *in, size_t inlen) { const char *func = "community"; + struct ibuf *buf; uint8_t flags, type, attr[256]; size_t skip = 2; uint16_t attr_len; @@ -80,26 +81,24 @@ test_parsing(size_t num, uint8_t *in, size_t inlen) return -1; } - switch (type) { - case ATTR_COMMUNITIES: - r = community_write(&comm, attr, sizeof(attr)); - break; - case ATTR_EXT_COMMUNITIES: - r = community_ext_write(&comm, 0, attr, sizeof(attr)); - break; - case ATTR_LARGE_COMMUNITIES: - r = community_large_write(&comm, attr, sizeof(attr)); - break; - } - - if (r != inlen) { - printf("Test %zu: %s_write return value %d != %zd\n", - num, func, r, inlen); + if ((buf = ibuf_dynamic(0, 4096)) == NULL) { + printf("Test %zu: ibuf_dynamic failed\n", num); return -1; } - if (r != -1 && memcmp(attr, in, inlen) != 0) { + + if (community_writebuf(&comm, type, 0, buf) == -1) { + printf("Test %zu: community_writebuf failed\n", num); + return -1; + } + + if (ibuf_size(buf) != inlen) { + printf("Test %zu: %s_write return value %zd != %zd\n", + num, func, ibuf_size(buf), inlen); + return -1; + } + if (memcmp(ibuf_data(buf), in, inlen) != 0) { printf("Test %zu: %s_write unexpected encoding: ", num, func); - dump(attr, inlen); + dump(ibuf_data(buf), ibuf_size(buf)); printf("expected: "); dump(in, inlen); return -1; @@ -225,45 +224,28 @@ log_warnx(const char *emsg, ...) va_end(ap); } -int -attr_write(void *p, uint16_t p_len, uint8_t flags, uint8_t type, - void *data, uint16_t data_len) -{ - u_char *b = p; - uint16_t tmp, tot_len = 2; /* attribute header (without len) */ - - flags &= ~ATTR_DEFMASK; - if (data_len > 255) { - tot_len += 2 + data_len; - flags |= ATTR_EXTLEN; - } else { - tot_len += 1 + data_len; - } - - if (tot_len > p_len) - return (-1); - - *b++ = flags; - *b++ = type; - if (data_len > 255) { - tmp = htons(data_len); - memcpy(b, &tmp, sizeof(tmp)); - b += 2; - } else - *b++ = (u_char)data_len; - - if (data == NULL) - return (tot_len - data_len); - - if (data_len != 0) - memcpy(b, data, data_len); - - return (tot_len); -} - int attr_writebuf(struct ibuf *buf, uint8_t flags, uint8_t type, void *data, uint16_t data_len) { - return (-1); + u_char hdr[4]; + + flags &= ~ATTR_DEFMASK; + if (data_len > 255) { + flags |= ATTR_EXTLEN; + hdr[2] = (data_len >> 8) & 0xff; + hdr[3] = data_len & 0xff; + } else { + hdr[2] = data_len & 0xff; + } + + hdr[0] = flags; + hdr[1] = type; + + if (ibuf_add(buf, hdr, flags & ATTR_EXTLEN ? 4 : 3) == -1) + return (-1); + if (data != NULL && ibuf_add(buf, data, data_len) == -1) + return (-1); + return (0); + } diff --git a/regress/usr.sbin/rpki-client/aspa/AS945.asa b/regress/usr.sbin/rpki-client/aspa/AS945.asa new file mode 100644 index 000000000..6c2f67092 Binary files /dev/null and b/regress/usr.sbin/rpki-client/aspa/AS945.asa differ diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 944823793..52192356d 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.397 2023/06/07 18:42:40 bluhm Exp $ +.\" $OpenBSD: ifconfig.8,v 1.398 2023/07/18 16:01:20 bluhm Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: June 7 2023 $ +.Dd $Mdocdate: July 18 2023 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -519,7 +519,6 @@ or Changing this option will re-initialize the network interface. .It Cm -tcplro Disable LRO. -LRO is disabled by default. .It Cm up Mark an interface .Dq up . diff --git a/sbin/iked/eap.c b/sbin/iked/eap.c index 06db86d37..137398d91 100644 --- a/sbin/iked/eap.c +++ b/sbin/iked/eap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eap.c,v 1.24 2023/05/23 13:57:14 claudio Exp $ */ +/* $OpenBSD: eap.c,v 1.25 2023/07/18 15:07:41 claudio Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -112,7 +112,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa) if ((pld = ikev2_add_payload(e)) == NULL) goto done; firstpayload = IKEV2_PAYLOAD_IDr; - if (ibuf_cat(e, id->id_buf) != 0) + if (ibuf_add_buf(e, id->id_buf) != 0) goto done; len = ibuf_size(id->id_buf); @@ -127,7 +127,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa) if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) goto done; cert->cert_type = certid->id_type; - if (ibuf_cat(e, certid->id_buf) != 0) + if (ibuf_add_buf(e, certid->id_buf) != 0) goto done; len = ibuf_size(certid->id_buf) + sizeof(*cert); @@ -142,7 +142,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa) if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) goto done; cert->cert_type = sa->sa_scert[i].id_type; - if (ibuf_cat(e, sa->sa_scert[i].id_buf) != 0) + if (ibuf_add_buf(e, sa->sa_scert[i].id_buf) != 0) goto done; len = ibuf_size(sa->sa_scert[i].id_buf) + sizeof(*cert); } @@ -157,7 +157,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa) if ((auth = ibuf_reserve(e, sizeof(*auth))) == NULL) goto done; auth->auth_method = sa->sa_localauth.id_type; - if (ibuf_cat(e, sa->sa_localauth.id_buf) != 0) + if (ibuf_add_buf(e, sa->sa_localauth.id_buf) != 0) goto done; len = ibuf_size(sa->sa_localauth.id_buf) + sizeof(*auth); diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h index dc97f6560..7b56e5655 100644 --- a/sbin/iked/iked.h +++ b/sbin/iked/iked.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iked.h,v 1.220 2023/06/28 14:10:24 tobhe Exp $ */ +/* $OpenBSD: iked.h,v 1.222 2023/07/18 15:07:41 claudio Exp $ */ /* * Copyright (c) 2019 Tobias Heider @@ -1268,12 +1268,10 @@ struct ibuf * ibuf_new(const void *, size_t); struct ibuf * ibuf_static(void); -int ibuf_cat(struct ibuf *, struct ibuf *); size_t ibuf_length(struct ibuf *); int ibuf_setsize(struct ibuf *, size_t); -void *ibuf_getdata(struct ibuf *, size_t); struct ibuf * - ibuf_get(struct ibuf *, size_t); + ibuf_getdata(struct ibuf *, size_t); struct ibuf * ibuf_dup(struct ibuf *); struct ibuf * diff --git a/sbin/iked/ikev2.c b/sbin/iked/ikev2.c index 88e7ad543..14e05a070 100644 --- a/sbin/iked/ikev2.c +++ b/sbin/iked/ikev2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2.c,v 1.372 2023/06/28 14:10:24 tobhe Exp $ */ +/* $OpenBSD: ikev2.c,v 1.374 2023/07/18 15:07:41 claudio Exp $ */ /* * Copyright (c) 2019 Tobias Heider @@ -1609,7 +1609,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa) if ((pld = ikev2_add_payload(e)) == NULL) goto done; firstpayload = IKEV2_PAYLOAD_IDi; - if (ibuf_cat(e, id->id_buf) != 0) + if (ibuf_add_buf(e, id->id_buf) != 0) goto done; len = ibuf_size(id->id_buf); @@ -1623,7 +1623,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa) goto done; if ((pld = ikev2_add_payload(e)) == NULL) goto done; - if (ibuf_cat(e, peerid.id_buf) != 0) + if (ibuf_add_buf(e, peerid.id_buf) != 0) goto done; len = ibuf_size(peerid.id_buf); } @@ -1639,7 +1639,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa) if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) goto done; cert->cert_type = certid->id_type; - if (ibuf_cat(e, certid->id_buf) != 0) + if (ibuf_add_buf(e, certid->id_buf) != 0) goto done; len = ibuf_size(certid->id_buf) + sizeof(*cert); @@ -1654,7 +1654,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa) if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) goto done; cert->cert_type = sa->sa_scert[i].id_type; - if (ibuf_cat(e, sa->sa_scert[i].id_buf) != 0) + if (ibuf_add_buf(e, sa->sa_scert[i].id_buf) != 0) goto done; len = ibuf_size(sa->sa_scert[i].id_buf) + sizeof(*cert); } @@ -1679,7 +1679,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa) if ((auth = ibuf_reserve(e, sizeof(*auth))) == NULL) goto done; auth->auth_method = sa->sa_localauth.id_type; - if (ibuf_cat(e, sa->sa_localauth.id_buf) != 0) + if (ibuf_add_buf(e, sa->sa_localauth.id_buf) != 0) goto done; len = ibuf_size(sa->sa_localauth.id_buf) + sizeof(*auth); @@ -2212,7 +2212,7 @@ ikev2_add_vendor_id(struct ibuf *e, struct ikev2_payload **pld, return (-1); if ((*pld = ikev2_add_payload(e)) == NULL) return (-1); - if (ibuf_cat(e, id) == -1) + if (ibuf_add_buf(e, id) == -1) return (-1); return (ibuf_length(id)); @@ -3908,7 +3908,7 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa) if ((pld = ikev2_add_payload(e)) == NULL) goto done; firstpayload = IKEV2_PAYLOAD_IDr; - if (ibuf_cat(e, id->id_buf) != 0) + if (ibuf_add_buf(e, id->id_buf) != 0) goto done; len = ibuf_size(id->id_buf); @@ -3924,7 +3924,7 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa) if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) goto done; cert->cert_type = certid->id_type; - if (ibuf_cat(e, certid->id_buf) != 0) + if (ibuf_add_buf(e, certid->id_buf) != 0) goto done; len = ibuf_size(certid->id_buf) + sizeof(*cert); @@ -3940,7 +3940,8 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa) sizeof(*cert))) == NULL) goto done; cert->cert_type = sa->sa_scert[i].id_type; - if (ibuf_cat(e, sa->sa_scert[i].id_buf) != 0) + if (ibuf_add_buf(e, sa->sa_scert[i].id_buf) != + 0) goto done; len = ibuf_size(sa->sa_scert[i].id_buf) + sizeof(*cert); @@ -3958,7 +3959,7 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa) if ((auth = ibuf_reserve(e, sizeof(*auth))) == NULL) goto done; auth->auth_method = sa->sa_localauth.id_type; - if (ibuf_cat(e, sa->sa_localauth.id_buf) != 0) + if (ibuf_add_buf(e, sa->sa_localauth.id_buf) != 0) goto done; len = ibuf_size(sa->sa_localauth.id_buf) + sizeof(*auth); @@ -4036,7 +4037,7 @@ ikev2_send_ike_e(struct iked *env, struct iked_sa *sa, struct ibuf *buf, goto done; if (buf) { - if (ibuf_cat(e, buf) != 0) + if (ibuf_add_buf(e, buf) != 0) goto done; if (ikev2_next_payload(pld, ibuf_size(buf), @@ -5320,7 +5321,7 @@ ikev2_send_informational(struct iked *env, struct iked_message *msg) log_debug("%s: encryption failed", __func__); goto done; } - if (ibuf_cat(buf, e) != 0) + if (ibuf_add_buf(buf, e) != 0) goto done; if (ikev2_next_payload(pld, ibuf_size(e), IKEV2_PAYLOAD_NOTIFY) == -1) @@ -5351,7 +5352,7 @@ ikev2_send_informational(struct iked *env, struct iked_message *msg) IKEV2_PAYLOAD_NOTIFY, IKEV2_EXCHANGE_INFORMATIONAL, 0)) == NULL) goto done; - if (ibuf_cat(buf, e) != 0) + if (ibuf_add_buf(buf, e) != 0) goto done; if (ikev2_set_header(hdr, ibuf_size(buf) - sizeof(*hdr)) == -1) goto done; @@ -5829,16 +5830,20 @@ ikev2_sa_keys(struct iked *env, struct iked_sa *sa, struct ibuf *key) goto done; } - /* ibuf_get() returns a new buffer from the next read offset */ - if ((sa->sa_key_d = ibuf_get(t, hash_length(prf))) == NULL || + /* ibuf_getdata() returns a new buffer from the next read offset */ + if ((sa->sa_key_d = ibuf_getdata(t, hash_length(prf))) == NULL || (!isaead && - (sa->sa_key_iauth = ibuf_get(t, hash_keylength(integr))) == NULL) || + (sa->sa_key_iauth = ibuf_getdata(t, hash_keylength(integr))) == + NULL) || (!isaead && - (sa->sa_key_rauth = ibuf_get(t, hash_keylength(integr))) == NULL) || - (sa->sa_key_iencr = ibuf_get(t, cipher_keylength(encr))) == NULL || - (sa->sa_key_rencr = ibuf_get(t, cipher_keylength(encr))) == NULL || - (sa->sa_key_iprf = ibuf_get(t, hash_length(prf))) == NULL || - (sa->sa_key_rprf = ibuf_get(t, hash_length(prf))) == NULL) { + (sa->sa_key_rauth = ibuf_getdata(t, hash_keylength(integr))) == + NULL) || + (sa->sa_key_iencr = ibuf_getdata(t, cipher_keylength(encr))) == + NULL || + (sa->sa_key_rencr = ibuf_getdata(t, cipher_keylength(encr))) == + NULL || + (sa->sa_key_iprf = ibuf_getdata(t, hash_length(prf))) == NULL || + (sa->sa_key_rprf = ibuf_getdata(t, hash_length(prf))) == NULL) { log_debug("%s: failed to get SA keys", SPI_SA(sa, __func__)); goto done; } @@ -6188,13 +6193,13 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa, ibuf_length(kex->kex_dhpeer)); goto done; } - if (ibuf_cat(seed, dhsecret) != 0) { + if (ibuf_add_buf(seed, dhsecret) != 0) { log_debug("%s: failed to set dh secret", __func__); goto done; } } - if (ibuf_cat(seed, kex->kex_inonce) != 0 || - ibuf_cat(seed, kex->kex_rnonce) != 0 || + if (ibuf_add_buf(seed, kex->kex_inonce) != 0 || + ibuf_add_buf(seed, kex->kex_rnonce) != 0 || (keymat = ikev2_prfplus(sa->sa_prf, sa->sa_key_d, seed, ilen)) == NULL) { log_debug("%s: failed to get IKE SA key material", __func__); @@ -6307,13 +6312,13 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa, csa->csa_spi.spi_size = 4; } - if (encrxf && (csa->csa_encrkey = ibuf_get(keymat, + if (encrxf && (csa->csa_encrkey = ibuf_getdata(keymat, encrxf->xform_keylength / 8)) == NULL) { log_debug("%s: failed to get CHILD SA encryption key", __func__); goto done; } - if (integrxf && (csa->csa_integrkey = ibuf_get(keymat, + if (integrxf && (csa->csa_integrkey = ibuf_getdata(keymat, integrxf->xform_keylength / 8)) == NULL) { log_debug("%s: failed to get CHILD SA integrity key", __func__); @@ -6340,13 +6345,13 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa, csb->csa_local = csa->csa_peer; csb->csa_peer = csa->csa_local; - if (encrxf && (csb->csa_encrkey = ibuf_get(keymat, + if (encrxf && (csb->csa_encrkey = ibuf_getdata(keymat, encrxf->xform_keylength / 8)) == NULL) { log_debug("%s: failed to get CHILD SA encryption key", __func__); goto done; } - if (integrxf && (csb->csa_integrkey = ibuf_get(keymat, + if (integrxf && (csb->csa_integrkey = ibuf_getdata(keymat, integrxf->xform_keylength / 8)) == NULL) { log_debug("%s: failed to get CHILD SA integrity key", __func__); diff --git a/sbin/iked/ikev2_msg.c b/sbin/iked/ikev2_msg.c index e694f8a1e..aa7e08d2e 100644 --- a/sbin/iked/ikev2_msg.c +++ b/sbin/iked/ikev2_msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2_msg.c,v 1.96 2023/06/28 14:10:24 tobhe Exp $ */ +/* $OpenBSD: ikev2_msg.c,v 1.97 2023/07/18 15:07:41 claudio Exp $ */ /* * Copyright (c) 2019 Tobias Heider @@ -300,7 +300,7 @@ ikev2_msg_send(struct iked *env, struct iked_message *msg) log_debug("%s: failed to set NAT-T", __func__); return (-1); } - if (ibuf_cat(new, buf) == -1) { + if (ibuf_add_buf(new, buf) == -1) { ibuf_free(new); log_debug("%s: failed to set NAT-T", __func__); return (-1); @@ -779,7 +779,7 @@ ikev2_msg_send_encrypt(struct iked *env, struct iked_sa *sa, struct ibuf **ep, log_debug("%s: encryption failed", __func__); goto done; } - if (ibuf_cat(buf, e) != 0) + if (ibuf_add_buf(buf, e) != 0) goto done; /* Add integrity checksum (HMAC) */ @@ -887,7 +887,7 @@ ikev2_send_encrypted_fragments(struct iked *env, struct iked_sa *sa, log_debug("%s: encryption failed", __func__); goto done; } - if (ibuf_cat(buf, e) != 0) + if (ibuf_add_buf(buf, e) != 0) goto done; /* Add integrity checksum (HMAC) */ @@ -961,7 +961,7 @@ ikev2_msg_auth(struct iked *env, struct iked_sa *sa, int response) if ((authmsg = ibuf_dup(buf)) == NULL) return (NULL); - if (ibuf_cat(authmsg, nonce) != 0) + if (ibuf_add_buf(authmsg, nonce) != 0) goto fail; if ((hash_setkey(sa->sa_prf, ibuf_data(prfkey), diff --git a/sbin/iked/imsg_util.c b/sbin/iked/imsg_util.c index eab8eea72..bf97af6f8 100644 --- a/sbin/iked/imsg_util.c +++ b/sbin/iked/imsg_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg_util.c,v 1.19 2023/06/19 17:19:50 claudio Exp $ */ +/* $OpenBSD: imsg_util.c,v 1.21 2023/07/18 15:07:41 claudio Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -36,12 +36,6 @@ * Extending the imsg buffer API for internal use */ -int -ibuf_cat(struct ibuf *dst, struct ibuf *src) -{ - return (ibuf_add(dst, src->buf, ibuf_size(src))); -} - struct ibuf * ibuf_new(const void *data, size_t len) { @@ -55,7 +49,7 @@ ibuf_new(const void *data, size_t len) return (buf); if (data == NULL) { - if (ibuf_reserve(buf, len) == NULL) { + if (ibuf_add_zero(buf, len) != 0) { ibuf_free(buf); return (NULL); } @@ -78,12 +72,12 @@ ibuf_static(void) size_t ibuf_length(struct ibuf *buf) { - if (buf == NULL || buf->buf == NULL) + if (buf == NULL) return (0); return (ibuf_size(buf)); } -void * +struct ibuf * ibuf_getdata(struct ibuf *buf, size_t len) { void *data; @@ -92,17 +86,6 @@ ibuf_getdata(struct ibuf *buf, size_t len) return (NULL); buf->rpos += len; - return (data); -} - -struct ibuf * -ibuf_get(struct ibuf *buf, size_t len) -{ - void *data; - - if ((data = ibuf_getdata(buf, len)) == NULL) - return (NULL); - return (ibuf_new(data, len)); } diff --git a/share/man/man9/namei.9 b/share/man/man9/namei.9 index 7b423a475..a297dd5f5 100644 --- a/share/man/man9/namei.9 +++ b/share/man/man9/namei.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: namei.9,v 1.22 2019/09/30 19:57:44 kn Exp $ +.\" $OpenBSD: namei.9,v 1.23 2023/07/15 23:01:25 kn Exp $ .\" $NetBSD: namei.9,v 1.9 2003/05/06 10:46:44 jmmv Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: September 30 2019 $ +.Dd $Mdocdate: July 15 2023 $ .Dt NAMEI 9 .Os .Sh NAME @@ -74,6 +74,8 @@ struct nameidata { */ struct vnode *ni_startdir; /* starting directory */ struct vnode *ni_rootdir; /* logical root directory */ + uint64_t ni_pledge; /* expected pledge for namei */ + u_char ni_unveil; /* required unveil flags for namei */ /* * Results: returned from/manipulated by lookup */ @@ -83,8 +85,9 @@ struct nameidata { * Shared between namei and lookup/commit routines. */ size_t ni_pathlen; /* remaining chars in path */ - const char *ni_next; /* next location in pathname */ + char *ni_next; /* next location in pathname */ u_long ni_loopcnt; /* count of symlinks encountered */ + struct unveil *ni_unveil_match; /* last matching unveil component */ /* * Lookup parameters */ @@ -147,6 +150,8 @@ add entry to the name cache this is last component of pathname .It ISSYMLINK symlink needs interpretation +.It REALPATH +save pathname buffer for realpath .It REQUIREDIR must be a directory .It STRIPSLASHES diff --git a/share/man/man9/refcnt_init.9 b/share/man/man9/refcnt_init.9 index 96fa94e7e..b75973629 100644 --- a/share/man/man9/refcnt_init.9 +++ b/share/man/man9/refcnt_init.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: refcnt_init.9,v 1.5 2023/07/06 20:53:53 kn Exp $ +.\" $OpenBSD: refcnt_init.9,v 1.6 2023/07/12 18:14:13 jmc Exp $ .\" .\" Copyright (c) 2015 David Gwynne .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 6 2023 $ +.Dd $Mdocdate: July 12 2023 $ .Dt REFCNT_INIT 9 .Os .Sh NAME @@ -71,7 +71,7 @@ is used to release an existing reference. is used to release an existing reference and wakes up a process that is currently waiting in .Fn refcnt_finalize -for all the references to released. +for all the references to be released. .Pp .Fn refcnt_finalize releases the caller's reference and sleeps until all the other diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c index 0bc736741..cf972316a 100644 --- a/sys/arch/amd64/amd64/cpu.c +++ b/sys/arch/amd64/amd64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.169 2023/06/15 22:18:06 cheloha Exp $ */ +/* $OpenBSD: cpu.c,v 1.170 2023/07/10 03:32:10 guenther Exp $ */ /* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -162,6 +162,7 @@ int cpu_perf_edx = 0; /* cpuid(0xa).edx */ int cpu_apmi_edx = 0; /* cpuid(0x80000007).edx */ int ecpu_ecxfeature = 0; /* cpuid(0x80000001).ecx */ int cpu_meltdown = 0; +int cpu_use_xsaves = 0; void replacesmap(void) @@ -699,10 +700,9 @@ cpu_attach(struct device *parent, struct device *self, void *aux) } static void -replacexsave(void) +replacexsave(int xsave_ext) { - extern long _xrstor, _xsave, _xsaveopt; - u_int32_t eax, ebx, ecx, edx; + extern long _xrstor, _xrstors, _xsave, _xsaves, _xsaveopt; static int replacedone = 0; int s; @@ -710,12 +710,13 @@ replacexsave(void) return; replacedone = 1; - /* find out whether xsaveopt is supported */ - CPUID_LEAF(0xd, 1, eax, ebx, ecx, edx); s = splhigh(); + codepatch_replace(CPTAG_XRSTORS, + (xsave_ext & XSAVE_XSAVES) ? &_xrstors : &_xrstor, 4); codepatch_replace(CPTAG_XRSTOR, &_xrstor, 4); codepatch_replace(CPTAG_XSAVE, - (eax & XSAVE_XSAVEOPT) ? &_xsaveopt : &_xsave, 4); + (xsave_ext & XSAVE_XSAVES) ? &_xsaves : + (xsave_ext & XSAVE_XSAVEOPT) ? &_xsaveopt : &_xsave, 4); splx(s); } @@ -764,20 +765,46 @@ cpu_init(struct cpu_info *ci) KASSERT(ebx == fpu_save_len); } - replacexsave(); + /* check for xsaves, xsaveopt, and supervisor features */ + CPUID_LEAF(0xd, 1, eax, ebx, ecx, edx); + /* Disable XSAVES on AMD family 17h due to Erratum 1386 */ + if (!strcmp(cpu_vendor, "AuthenticAMD") && + ci->ci_family == 0x17) { + eax &= ~XSAVE_XSAVES; + } + if (eax & XSAVE_XSAVES) { +#ifndef SMALL_KERNEL + if (ci->ci_feature_sefflags_edx & SEFF0EDX_IBT) + xsave_mask |= ecx & XFEATURE_CET_U; +#endif + if (xsave_mask & XFEATURE_XSS_MASK) { + wrmsr(MSR_XSS, xsave_mask & XFEATURE_XSS_MASK); + CPUID_LEAF(0xd, 1, eax, ebx, ecx, edx); + KASSERT(ebx <= sizeof(struct savefpu)); + } + if (CPU_IS_PRIMARY(ci)) + cpu_use_xsaves = 1; + } + + replacexsave(eax); } - /* Give proc0 a clean FPU save area */ - sfp = &proc0.p_addr->u_pcb.pcb_savefpu; - memset(sfp, 0, fpu_save_len); - sfp->fp_fxsave.fx_fcw = __INITIAL_NPXCW__; - sfp->fp_fxsave.fx_mxcsr = __INITIAL_MXCSR__; - fpureset(); - if (xsave_mask) { - /* must not use xsaveopt here */ - xsave(sfp, xsave_mask); - } else - fxsave(sfp); + if (CPU_IS_PRIMARY(ci)) { + /* Clean our FPU save area */ + sfp = fpu_cleandata; + memset(sfp, 0, fpu_save_len); + sfp->fp_fxsave.fx_fcw = __INITIAL_NPXCW__; + sfp->fp_fxsave.fx_mxcsr = __INITIAL_MXCSR__; + xrstor_user(sfp, xsave_mask); + if (cpu_use_xsaves || !xsave_mask) + fpusave(sfp); + else { + /* must not use xsaveopt here */ + xsave(sfp, xsave_mask); + } + } else { + fpureset(); + } #if NVMM > 0 /* Re-enable VMM if needed */ diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index 5aa695e39..c87098e3b 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.135 2023/07/05 18:23:10 anton Exp $ */ +/* $OpenBSD: locore.S,v 1.136 2023/07/10 03:32:10 guenther Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -342,7 +342,7 @@ switch_exited: #endif CODEPATCH_START fxrstor64 (%rdi) - CODEPATCH_END(CPTAG_XRSTOR) + CODEPATCH_END(CPTAG_XRSTORS) andl $~CPUPF_USERXSTATE,CPUVAR(PFLAGS) .Lxstate_reset: @@ -680,7 +680,7 @@ KUTEXT_PAGE_END /* untouched state so can't fault */ CODEPATCH_START fxrstor64 (%rdi) - CODEPATCH_END(CPTAG_XRSTOR) + CODEPATCH_END(CPTAG_XRSTORS) #if PCB_SAVEFPU != 0 subq $PCB_SAVEFPU,%rdi #endif @@ -868,10 +868,14 @@ KTEXT_PAGE_END #if PCB_SAVEFPU != 0 addq $PCB_SAVEFPU,%rdi #endif - movq xsave_mask(%rip),%rsi - call xrstor_user - testl %eax,%eax - jnz .Lintr_xrstor_faulted + movq xsave_mask(%rip),%rdx + movl %edx,%eax + shrq $32, %rdx + CODEPATCH_START + fxrstor64 (%rdi) + CODEPATCH_END(CPTAG_XRSTORS) + //testl %eax,%eax + //jnz .Lintr_xrstor_faulted .Lintr_restore_fsbase: /* CPU doesn't have curproc's FS.base */ orl $CPUPF_USERSEGS,CPUVAR(PFLAGS) movq CPUVAR(CURPCB),%rdx @@ -894,7 +898,7 @@ KTEXT_PAGE_END #endif CODEPATCH_START fxrstor64 (%rdi) - CODEPATCH_END(CPTAG_XRSTOR) + CODEPATCH_END(CPTAG_XRSTORS) movq $T_PROTFLT,TF_TRAPNO(%rsp) jmp recall_trap @@ -945,7 +949,6 @@ NENTRY(intr_fast_exit) testq $PSL_I,%rdx jnz .Lintr_exit_not_blocked #endif /* DIAGNOSTIC */ - call pku_xonly /* XXX guenther disapproves, but foo3 locks */ movq TF_RDI(%rsp),%rdi movq TF_RSI(%rsp),%rsi movq TF_R8(%rsp),%r8 @@ -992,8 +995,14 @@ END(intr_fast_exit) /* * FPU/"extended CPU state" handling + * void xrstor_kern(sfp, mask) + * using first of xrstors/xrstor/fxrstor, load given state + * which is assumed to be trusted: i.e., unaltered from + * xsaves/xsaveopt/xsave/fxsave by kernel * int xrstor_user(sfp, mask) - * load given state, returns 0/1 if okay/it trapped + * using first of xrstor/fxrstor, load given state which might + * not be trustable: #GP faults will be caught; returns 0/1 if + * okay/it trapped. * void fpusave(sfp) * save current state, but retain it in the FPU * void fpusavereset(sfp) @@ -1002,6 +1011,19 @@ END(intr_fast_exit) * load specified %xcr# register, returns 0/1 if okay/it trapped */ +ENTRY(xrstor_kern) + RETGUARD_SETUP(xrstor_kern, r11) + movq %rsi, %rdx + movl %esi, %eax + shrq $32, %rdx + CODEPATCH_START + fxrstor64 (%rdi) + CODEPATCH_END(CPTAG_XRSTORS) + RETGUARD_CHECK(xrstor_kern, r11) + ret + lfence +END(xrstor_kern) + ENTRY(xrstor_user) RETGUARD_SETUP(xrstor_user, r11) movq %rsi, %rdx @@ -1050,7 +1072,7 @@ ENTRY(fpusavereset) #endif CODEPATCH_START fxrstor64 (%rdi) - CODEPATCH_END(CPTAG_XRSTOR) + CODEPATCH_END(CPTAG_XRSTORS) RETGUARD_CHECK(fpusavereset, r11) ret lfence @@ -1081,9 +1103,17 @@ END(xsetbv_user) _xrstor: xrstor64 (%rdi) + .globl _xrstors +_xrstors: + xrstors64 (%rdi) + .globl _xsave _xsave: - xsave64 (%rdi) + xsave64 (%rdi) + + .globl _xsaves +_xsaves: + xsaves64 (%rdi) .globl _xsaveopt _xsaveopt: diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index cec6ee378..ddbeedb12 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.284 2022/11/29 21:41:39 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.285 2023/07/10 03:32:10 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -564,6 +564,63 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, /* NOTREACHED */ } +static inline void +maybe_enable_user_cet(struct proc *p) +{ +#ifndef SMALL_KERNEL + /* Enable indirect-branch tracking if present and not disabled */ + if ((xsave_mask & XFEATURE_CET_U) && + (p->p_p->ps_flags & PS_NOBTCFI) == 0) { + uint64_t msr = rdmsr(MSR_U_CET); + wrmsr(MSR_U_CET, msr | MSR_CET_ENDBR_EN | MSR_CET_NO_TRACK_EN); + } +#endif +} + +static inline void +initialize_thread_xstate(struct proc *p) +{ + if (cpu_use_xsaves) { + xrstors(fpu_cleandata, xsave_mask); + maybe_enable_user_cet(p); + } else { + /* Reset FPU state in PCB */ + memcpy(&p->p_addr->u_pcb.pcb_savefpu, fpu_cleandata, + fpu_save_len); + + if (curcpu()->ci_pflags & CPUPF_USERXSTATE) { + /* state in CPU is obsolete; reset it */ + fpureset(); + } + } + + /* The reset state _is_ the userspace state for this thread now */ + curcpu()->ci_pflags |= CPUPF_USERXSTATE; +} + +/* + * Copy out the FPU state, massaging it to be usable from userspace + * and acceptable to xrstor_user() + */ +static inline int +copyoutfpu(struct savefpu *sfp, char *sp, size_t len) +{ + uint64_t bvs[2]; + + if (copyout(sfp, sp, len)) + return 1; + if (len > offsetof(struct savefpu, fp_xstate.xstate_bv)) { + sp += offsetof(struct savefpu, fp_xstate.xstate_bv); + len -= offsetof(struct savefpu, fp_xstate.xstate_bv); + bvs[0] = sfp->fp_xstate.xstate_bv & XFEATURE_XCR0_MASK; + bvs[1] = sfp->fp_xstate.xstate_xcomp_bv & + (XFEATURE_XCR0_MASK | XFEATURE_COMPRESSED); + if (copyout(bvs, sp, min(len, sizeof bvs))) + return 1; + } + return 0; +} + /* * Send an interrupt to process. * @@ -613,23 +670,22 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip, else sp = tf->tf_rsp - 128; - sp &= ~15ULL; /* just in case */ - sss = (sizeof(ksc) + 15) & ~15; + sp -= fpu_save_len; + if (cpu_use_xsaves) + sp &= ~63ULL; /* just in case */ + else + sp &= ~15ULL; /* just in case */ /* Save FPU state to PCB if necessary, then copy it out */ - if (curcpu()->ci_pflags & CPUPF_USERXSTATE) { - curcpu()->ci_pflags &= ~CPUPF_USERXSTATE; - fpusavereset(&p->p_addr->u_pcb.pcb_savefpu); - } - sp -= fpu_save_len; - ksc.sc_fpstate = (struct fxsave64 *)sp; - if (copyout(sfp, (void *)sp, fpu_save_len)) + if (curcpu()->ci_pflags & CPUPF_USERXSTATE) + fpusave(&p->p_addr->u_pcb.pcb_savefpu); + if (copyoutfpu(sfp, (void *)sp, fpu_save_len)) return 1; - /* Now reset the FPU state in PCB */ - memcpy(&p->p_addr->u_pcb.pcb_savefpu, - &proc0.p_addr->u_pcb.pcb_savefpu, fpu_save_len); + initialize_thread_xstate(p); + ksc.sc_fpstate = (struct fxsave64 *)sp; + sss = (sizeof(ksc) + 15) & ~15; sip = 0; if (info) { sip = sp - ((sizeof(*ksip) + 15) & ~15); @@ -658,9 +714,6 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip, tf->tf_rsp = scp; tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL); - /* The reset state _is_ the userspace state for this thread now */ - curcpu()->ci_pflags |= CPUPF_USERXSTATE; - return 0; } @@ -682,6 +735,7 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) } */ *uap = v; struct sigcontext ksc, *scp = SCARG(uap, sigcntxp); struct trapframe *tf = p->p_md.md_regs; + struct savefpu *sfp = &p->p_addr->u_pcb.pcb_savefpu; int error; if (PROC_PC(p) != p->p_p->ps_sigcoderet) { @@ -706,7 +760,7 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) !USERMODE(ksc.sc_cs, ksc.sc_eflags)) return (EINVAL); - /* Current state is obsolete; toss it and force a reload */ + /* Current FPU state is obsolete; toss it and force a reload */ if (curcpu()->ci_pflags & CPUPF_USERXSTATE) { curcpu()->ci_pflags &= ~CPUPF_USERXSTATE; fpureset(); @@ -714,15 +768,17 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) /* Copy in the FPU state to restore */ if (__predict_true(ksc.sc_fpstate != NULL)) { - struct fxsave64 *fx = &p->p_addr->u_pcb.pcb_savefpu.fp_fxsave; - - if ((error = copyin(ksc.sc_fpstate, fx, fpu_save_len))) - return (error); - fx->fx_mxcsr &= fpu_mxcsr_mask; + if ((error = copyin(ksc.sc_fpstate, sfp, fpu_save_len))) + return error; + if (xrstor_user(sfp, xsave_mask)) { + memcpy(sfp, fpu_cleandata, fpu_save_len); + return EINVAL; + } + maybe_enable_user_cet(p); + curcpu()->ci_pflags |= CPUPF_USERXSTATE; } else { /* shouldn't happen, but handle it */ - memcpy(&p->p_addr->u_pcb.pcb_savefpu, - &proc0.p_addr->u_pcb.pcb_savefpu, fpu_save_len); + initialize_thread_xstate(p); } tf->tf_rdi = ksc.sc_rdi; @@ -1146,17 +1202,7 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack, { struct trapframe *tf; - /* Reset FPU state in PCB */ - memcpy(&p->p_addr->u_pcb.pcb_savefpu, - &proc0.p_addr->u_pcb.pcb_savefpu, fpu_save_len); - - if (curcpu()->ci_pflags & CPUPF_USERXSTATE) { - /* state in CPU is obsolete; reset it */ - fpureset(); - } else { - /* the reset state _is_ the userspace state now */ - curcpu()->ci_pflags |= CPUPF_USERXSTATE; - } + initialize_thread_xstate(p); /* To reset all registers we have to return via iretq */ p->p_md.md_flags |= MDP_IRET; diff --git a/sys/arch/amd64/amd64/vmm_machdep.c b/sys/arch/amd64/amd64/vmm_machdep.c index dc30e35a8..24a376a8f 100644 --- a/sys/arch/amd64/amd64/vmm_machdep.c +++ b/sys/arch/amd64/amd64/vmm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm_machdep.c,v 1.3 2023/04/26 15:40:51 mlarkin Exp $ */ +/* $OpenBSD: vmm_machdep.c,v 1.4 2023/07/10 03:32:10 guenther Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -3733,13 +3733,8 @@ vmm_fpurestore(struct vcpu *vcpu) fpusavereset(&curproc->p_addr->u_pcb.pcb_savefpu); } - if (vcpu->vc_fpuinited) { - if (xrstor_user(&vcpu->vc_g_fpu, xsave_mask)) { - DPRINTF("%s: guest attempted to set invalid %s\n", - __func__, "xsave/xrstor state"); - return EINVAL; - } - } + if (vcpu->vc_fpuinited) + xrstor_kern(&vcpu->vc_g_fpu, xsave_mask); if (xsave_mask) { /* Restore guest %xcr0 */ @@ -3769,7 +3764,7 @@ vmm_fpusave(struct vcpu *vcpu) vcpu->vc_gueststate.vg_xcr0 = xgetbv(0); /* Restore host %xcr0 */ - xsetbv(0, xsave_mask); + xsetbv(0, xsave_mask & XFEATURE_XCR0_MASK); } /* diff --git a/sys/arch/amd64/conf/RAMDISK b/sys/arch/amd64/conf/RAMDISK index 84068934a..553047254 100644 --- a/sys/arch/amd64/conf/RAMDISK +++ b/sys/arch/amd64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.85 2021/12/26 13:55:36 kettenis Exp $ +# $OpenBSD: RAMDISK,v 1.86 2023/07/20 02:26:24 yasuoka Exp $ machine amd64 maxusers 4 @@ -77,7 +77,7 @@ pckbd* at pckbc? # PC keyboard wskbd* at pckbd? mux 1 vga0 at isa? vga* at pci? -wsdisplay* at vga? +wsdisplay0 at vga? console 1 com0 at isa? port 0x3f8 irq 4 # standard PC serial ports com1 at isa? port 0x2f8 irq 3 diff --git a/sys/arch/amd64/conf/RAMDISK_CD b/sys/arch/amd64/conf/RAMDISK_CD index bdde32abc..4bdf5bb6f 100644 --- a/sys/arch/amd64/conf/RAMDISK_CD +++ b/sys/arch/amd64/conf/RAMDISK_CD @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK_CD,v 1.201 2023/04/02 03:40:54 kevlo Exp $ +# $OpenBSD: RAMDISK_CD,v 1.202 2023/07/20 02:26:24 yasuoka Exp $ machine amd64 maxusers 4 @@ -152,7 +152,7 @@ pckbd* at pckbc? # PC keyboard wskbd* at pckbd? mux 1 vga0 at isa? vga* at pci? -wsdisplay* at vga? +wsdisplay0 at vga? console 1 efifb0 at mainbus? # EFI Framebuffer wsdisplay0 at efifb? console 1 diff --git a/sys/arch/amd64/include/codepatch.h b/sys/arch/amd64/include/codepatch.h index a4d8a6095..50618bdda 100644 --- a/sys/arch/amd64/include/codepatch.h +++ b/sys/arch/amd64/include/codepatch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: codepatch.h,v 1.14 2020/03/11 07:27:08 guenther Exp $ */ +/* $OpenBSD: codepatch.h,v 1.15 2023/07/10 03:32:10 guenther Exp $ */ /* * Copyright (c) 2014-2015 Stefan Fritsch * @@ -65,6 +65,7 @@ void codepatch_disable(void); #define CPTAG_MDS_VMM 10 #define CPTAG_FENCE_SWAPGS_MIS_TAKEN 11 #define CPTAG_FENCE_NO_SAFE_SMAP 12 +#define CPTAG_XRSTORS 13 /* * stac/clac SMAP instructions have lfence like semantics. Let's diff --git a/sys/arch/amd64/include/fpu.h b/sys/arch/amd64/include/fpu.h index 6f05c9e6a..2a024f2dc 100644 --- a/sys/arch/amd64/include/fpu.h +++ b/sys/arch/amd64/include/fpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.h,v 1.18 2023/05/22 00:39:57 guenther Exp $ */ +/* $OpenBSD: fpu.h,v 1.19 2023/07/10 03:32:10 guenther Exp $ */ /* $NetBSD: fpu.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ #ifndef _MACHINE_FPU_H_ @@ -40,6 +40,7 @@ struct savefpu { struct fxsave64 fp_fxsave; /* see above */ struct xstate_hdr fp_xstate; u_int64_t fp_ymm[16][2]; + u_int64_t fp_cet_u[2]; }; /* @@ -60,6 +61,7 @@ struct cpu_info; extern size_t fpu_save_len; extern uint32_t fpu_mxcsr_mask; extern uint64_t xsave_mask; +extern int cpu_use_xsaves; void fpuinit(struct cpu_info *); int fputrap(int _type); @@ -68,9 +70,13 @@ void fpusavereset(struct savefpu *); void fpu_kernel_enter(void); void fpu_kernel_exit(void); +/* pointer to fxsave/xsave/xsaves data with everything reset */ +#define fpu_cleandata (&proc0.p_addr->u_pcb.pcb_savefpu) + int xrstor_user(struct savefpu *_addr, uint64_t _mask); +void xrstor_kern(struct savefpu *_addr, uint64_t _mask); #define fpureset() \ - xrstor_user(&proc0.p_addr->u_pcb.pcb_savefpu, xsave_mask) + xrstor_kern(fpu_cleandata, xsave_mask) int xsetbv_user(uint32_t _reg, uint64_t _mask); #define fninit() __asm("fninit") @@ -87,9 +93,17 @@ xsave(struct savefpu *addr, uint64_t mask) lo = mask; hi = mask >> 32; - /* should be xsave64, but where we use this it doesn't matter */ - __asm volatile("xsave %0" : "=m" (*addr) : "a" (lo), "d" (hi) : - "memory"); + __asm volatile("xsave64 %0" : "+m" (*addr) : "a" (lo), "d" (hi)); +} + +static inline void +xrstors(const struct savefpu *addr, uint64_t mask) +{ + uint32_t lo, hi; + + lo = mask; + hi = mask >> 32; + __asm volatile("xrstors64 %0" : : "m" (*addr), "a" (lo), "d" (hi)); } #endif diff --git a/sys/arch/amd64/include/specialreg.h b/sys/arch/amd64/include/specialreg.h index e24c5322d..ca1eb336d 100644 --- a/sys/arch/amd64/include/specialreg.h +++ b/sys/arch/amd64/include/specialreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specialreg.h,v 1.102 2023/04/22 18:27:28 guenther Exp $ */ +/* $OpenBSD: specialreg.h,v 1.103 2023/07/10 03:32:10 guenther Exp $ */ /* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */ /* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */ @@ -118,6 +118,9 @@ #define XFEATURE_TILEDATA 0x00040000 /* AMX state */ #define XFEATURE_AMX (XFEATURE_TILEDATA | XFEATURE_TILEDATA) +/* valid only in xcomp_bv field: */ +#define XFEATURE_COMPRESSED (1ULL << 63) /* compressed format */ + /* which bits are for XCR0 and which for the XSS MSR? */ #define XFEATURE_XCR0_MASK \ (XFEATURE_X87 | XFEATURE_SSE | XFEATURE_AVX | XFEATURE_MPX | \ @@ -525,6 +528,7 @@ #define MSR_MC3_MISC 0x413 #define MSR_U_CET 0x6a0 #define MSR_CET_ENDBR_EN (1 << 2) +#define MSR_CET_NO_TRACK_EN (1 << 4) #define MSR_S_CET 0x6a2 #define MSR_PKRS 0x6e1 #define MSR_XSS 0xda0 diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index ae6bb2072..ae78cd2a2 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.95 2023/06/15 22:18:07 cheloha Exp $ */ +/* $OpenBSD: cpu.c,v 1.97 2023/07/16 16:13:46 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -1010,6 +1010,8 @@ void cpu_boot_secondary(struct cpu_info *ci); void cpu_hatch_secondary(void); void cpu_hatch_secondary_spin(void); +void cpu_suspend_cycle(void); + void cpu_boot_secondary_processors(void) { @@ -1224,7 +1226,7 @@ cpu_halt(void) ci->ci_psci_suspend_param = 0; } else #endif - __asm volatile("wfi"); + cpu_suspend_cycle(); count++; } @@ -1236,8 +1238,6 @@ cpu_halt(void) /* Unmask clock interrupts. */ WRITE_SPECIALREG(cntv_ctl_el0, READ_SPECIALREG(cntv_ctl_el0) & ~CNTV_CTL_IMASK); - - printf("%s: %d wakeup events\n", ci->ci_dev->dv_xname, count); } void @@ -1266,9 +1266,16 @@ cpu_unidle(struct cpu_info *ci) void cpu_hatch_primary(void); +void (*cpu_suspend_cycle_fcn)(void) = cpu_wfi; label_t cpu_suspend_jmpbuf; int cpu_suspended; +void +cpu_suspend_cycle(void) +{ + cpu_suspend_cycle_fcn(); +} + void cpu_init_primary(void) { @@ -1342,7 +1349,7 @@ cpu_suspend_primary(void) ci->ci_psci_suspend_param = 0; } else #endif - __asm volatile("wfi"); + cpu_suspend_cycle(); count++; } @@ -1353,8 +1360,6 @@ resume: WRITE_SPECIALREG(cntv_ctl_el0, READ_SPECIALREG(cntv_ctl_el0) & ~CNTV_CTL_IMASK); - printf("%s: %d wakeup events\n", ci->ci_dev->dv_xname, count); - return 0; } diff --git a/sys/arch/arm64/arm64/cpufunc_asm.S b/sys/arch/arm64/arm64/cpufunc_asm.S index c243f6141..d73e296f6 100644 --- a/sys/arch/arm64/arm64/cpufunc_asm.S +++ b/sys/arch/arm64/arm64/cpufunc_asm.S @@ -1,4 +1,4 @@ -/* $OpenBSD: cpufunc_asm.S,v 1.7 2020/11/20 21:48:33 patrick Exp $ */ +/* $OpenBSD: cpufunc_asm.S,v 1.8 2023/07/13 08:33:36 kettenis Exp $ */ /*- * Copyright (c) 2014 Robin Randhawa * Copyright (c) 2015 The FreeBSD Foundation @@ -185,3 +185,52 @@ ENTRY(cpu_icache_sync_range) RETGUARD_CHECK(cpu_icache_sync_range, x15) ret END(cpu_icache_sync_range) + +ENTRY(cpu_wfi) + RETGUARD_SETUP(cpu_wfi, x15) + dsb sy + wfi + RETGUARD_CHECK(cpu_wfi, x15) + ret +END(cpu_wfi) + +ENTRY(aplcpu_deep_wfi) + RETGUARD_SETUP(aplcpu_deep_wfi, x15) + + stp x30, x15, [sp, #-16]! + stp x28, x29, [sp, #-16]! + stp x26, x27, [sp, #-16]! + stp x24, x25, [sp, #-16]! + stp x22, x23, [sp, #-16]! + stp x20, x21, [sp, #-16]! + stp x18, x19, [sp, #-16]! + + mrs x0, daif + str x0, [sp, #-16]! + msr daifset, #3 + + mrs x0, s3_5_c15_c5_0 + orr x0, x0, #(3 << 24) + msr s3_5_c15_c5_0, x0 + + dsb sy + wfi + + mrs x0, s3_5_c15_c5_0 + bic x0, x0, #(1 << 24) + msr s3_5_c15_c5_0, x0 + + ldr x0, [sp], #16 + msr daif, x0 + + ldp x18, x19, [sp], #16 + ldp x20, x21, [sp], #16 + ldp x22, x23, [sp], #16 + ldp x24, x25, [sp], #16 + ldp x26, x27, [sp], #16 + ldp x28, x29, [sp], #16 + ldp x30, x15, [sp], #16 + + RETGUARD_CHECK(aplcpu_deep_wfi, x15) + ret +END(aplcpu_deep_wfi) diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index 1a582fa27..6b2dcba9c 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.82 2023/06/10 19:30:48 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.83 2023/07/13 08:33:36 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * Copyright (c) 2021 Mark Kettenis @@ -211,12 +211,13 @@ cpu_idle_enter(void) { } +void (*cpu_idle_cycle_fcn)(void) = cpu_wfi; + void cpu_idle_cycle(void) { enable_irq_daif(); - __asm volatile("dsb sy" ::: "memory"); - __asm volatile("wfi"); + cpu_idle_cycle_fcn(); } void diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index 8d83d1af4..faa9ffb03 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.275 2023/07/01 16:34:29 drahn Exp $ +# $OpenBSD: GENERIC,v 1.276 2023/07/19 20:27:20 kettenis Exp $ # # GENERIC machine description file # @@ -177,7 +177,7 @@ nvme* at aplns? aplpcie* at fdt? pci* at aplpcie? aplpinctrl* at fdt? early 1 -aplpmgr* at fdt? early 1 +aplpmgr* at fdt? early 2 aplpwm* at fdt? aplrtk* at fdt? aplsart* at fdt? diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK index 62c1a3e6c..d278b8d83 100644 --- a/sys/arch/arm64/conf/RAMDISK +++ b/sys/arch/arm64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.207 2023/06/27 22:38:46 patrick Exp $ +# $OpenBSD: RAMDISK,v 1.208 2023/07/19 20:27:20 kettenis Exp $ machine arm64 maxusers 4 @@ -128,7 +128,7 @@ nvme* at aplns? aplpcie* at fdt? pci* at aplpcie? aplpinctrl* at fdt? early 1 -aplpmgr* at fdt? early 1 +aplpmgr* at fdt? early 2 aplrtk* at fdt? aplsart* at fdt? aplsmc* at fdt? diff --git a/sys/arch/arm64/dev/aplcpu.c b/sys/arch/arm64/dev/aplcpu.c index 97fa69df9..9c1d3a978 100644 --- a/sys/arch/arm64/dev/aplcpu.c +++ b/sys/arch/arm64/dev/aplcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplcpu.c,v 1.7 2023/05/09 10:13:23 kettenis Exp $ */ +/* $OpenBSD: aplcpu.c,v 1.8 2023/07/13 08:33:36 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -42,6 +42,8 @@ #define DVFS_T8112_STATUS_CUR_PS_MASK (0x1f << 5) #define DVFS_T8112_STATUS_CUR_PS_SHIFT 5 +#define APLCPU_DEEP_WFI_LATENCY 10 /* microseconds */ + struct opp { uint64_t opp_hz; uint32_t opp_level; @@ -97,6 +99,8 @@ uint32_t aplcpu_opp_level(struct aplcpu_softc *, int); int aplcpu_clockspeed(int *); void aplcpu_setperf(int level); void aplcpu_refresh_sensors(void *); +void aplcpu_idle_cycle(); +void aplcpu_deep_wfi(void); int aplcpu_match(struct device *parent, void *match, void *aux) @@ -171,6 +175,8 @@ aplcpu_attach(struct device *parent, struct device *self, void *aux) sensordev_install(&sc->sc_sensordev); sensor_task_register(sc, aplcpu_refresh_sensors, 1); + cpu_idle_cycle_fcn = aplcpu_idle_cycle; + cpu_suspend_cycle_fcn = aplcpu_deep_wfi; cpu_cpuspeed = aplcpu_clockspeed; cpu_setperf = aplcpu_setperf; return; @@ -223,11 +229,8 @@ aplcpu_opp_init(struct aplcpu_softc *sc, int node) return; count = 0; - for (child = OF_child(node); child != 0; child = OF_peer(child)) { - if (OF_getproplen(child, "turbo-mode") == 0) - continue; + for (child = OF_child(node); child != 0; child = OF_peer(child)) count++; - } if (count == 0) return; @@ -239,8 +242,6 @@ aplcpu_opp_init(struct aplcpu_softc *sc, int node) count = 0; for (child = OF_child(node); child != 0; child = OF_peer(child)) { - if (OF_getproplen(child, "turbo-mode") == 0) - continue; opp_hz = OF_getpropint64(child, "opp-hz", 0); opp_level = OF_getpropint(child, "opp-level", 0); @@ -430,3 +431,27 @@ aplcpu_refresh_sensors(void *arg) } } } + +void +aplcpu_idle_cycle(void) +{ + struct cpu_info *ci = curcpu(); + struct timeval start, stop; + u_long itime; + + microuptime(&start); + + if (ci->ci_prev_sleep > 3 * APLCPU_DEEP_WFI_LATENCY) + aplcpu_deep_wfi(); + else + cpu_wfi(); + + microuptime(&stop); + timersub(&stop, &start, &stop); + itime = stop.tv_sec * 1000000 + stop.tv_usec; + + ci->ci_last_itime = itime; + itime >>= 1; + ci->ci_prev_sleep = (ci->ci_prev_sleep + (ci->ci_prev_sleep >> 1) + + itime) >> 1; +} diff --git a/sys/arch/arm64/dev/aplpmgr.c b/sys/arch/arm64/dev/aplpmgr.c index 2525a447e..b7d8e830b 100644 --- a/sys/arch/arm64/dev/aplpmgr.c +++ b/sys/arch/arm64/dev/aplpmgr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplpmgr.c,v 1.3 2022/11/10 11:44:06 kettenis Exp $ */ +/* $OpenBSD: aplpmgr.c,v 1.5 2023/07/20 20:40:44 kettenis Exp $ */ /* * Copyright (c) 2021 Mark Kettenis * @@ -66,7 +66,6 @@ struct aplpmgr_softc { int aplpmgr_match(struct device *, void *, void *); void aplpmgr_attach(struct device *, struct device *, void *); -int aplpmgr_activate(struct device *, int act); const struct cfattach aplpmgr_ca = { sizeof (struct aplpmgr_softc), aplpmgr_match, aplpmgr_attach diff --git a/sys/arch/arm64/dev/aplsmc.c b/sys/arch/arm64/dev/aplsmc.c index 1fc9692ac..28f77c807 100644 --- a/sys/arch/arm64/dev/aplsmc.c +++ b/sys/arch/arm64/dev/aplsmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplsmc.c,v 1.24 2023/07/08 14:44:43 tobhe Exp $ */ +/* $OpenBSD: aplsmc.c,v 1.25 2023/07/16 16:11:11 kettenis Exp $ */ /* * Copyright (c) 2021 Mark Kettenis * @@ -138,6 +138,7 @@ struct aplsmc_softc { struct ksensor sc_sensors[APLSMC_MAX_SENSORS]; int sc_nsensors; struct ksensordev sc_sensordev; + uint32_t sc_suspend_pstr; }; #define CH0I_DISCHARGE (1 << 0) @@ -175,9 +176,11 @@ struct aplsmc_sensor aplsmc_sensors[] = { int aplsmc_match(struct device *, void *, void *); void aplsmc_attach(struct device *, struct device *, void *); +int aplsmc_activate(struct device *, int); const struct cfattach aplsmc_ca = { - sizeof (struct aplsmc_softc), aplsmc_match, aplsmc_attach + sizeof (struct aplsmc_softc), aplsmc_match, aplsmc_attach, + NULL, aplsmc_activate }; struct cfdriver aplsmc_cd = { @@ -189,6 +192,7 @@ int aplsmc_send_cmd(struct aplsmc_softc *, uint16_t, uint32_t, uint16_t); int aplsmc_wait_cmd(struct aplsmc_softc *sc); int aplsmc_read_key(struct aplsmc_softc *, uint32_t, void *, size_t); int aplsmc_write_key(struct aplsmc_softc *, uint32_t, void *, size_t); +int64_t aplsmc_convert_flt(uint32_t, int); void aplsmc_refresh_sensors(void *); int aplsmc_apminfo(struct apm_power_info *); void aplsmc_set_pin(void *, uint32_t *, int); @@ -357,7 +361,24 @@ aplsmc_attach(struct device *parent, struct device *self, void *aux) #ifdef SUSPEND device_register_wakeup(&sc->sc_dev); #endif +} +int +aplsmc_activate(struct device *self, int act) +{ +#ifdef SUSPEND + struct aplsmc_softc *sc = (struct aplsmc_softc *)self; + int64_t value; + + switch (act) { + case DVACT_WAKEUP: + value = aplsmc_convert_flt(sc->sc_suspend_pstr, 100); + printf("%s: system %lld.%02lld W\n", sc->sc_dev.dv_xname, + value / 100, value % 100); + } +#endif + + return 0; } void @@ -366,8 +387,12 @@ aplsmc_handle_notification(struct aplsmc_softc *sc, uint64_t data) extern int allowpowerdown; #ifdef SUSPEND extern int cpu_suspended; + uint32_t flt = 0; if (cpu_suspended) { + aplsmc_read_key(sc, 'PSTR', &flt, sizeof(flt)); + sc->sc_suspend_pstr = flt; + switch (SMC_EV_TYPE(data)) { case SMC_EV_TYPE_BTN: switch (SMC_EV_SUBTYPE(data)) { @@ -542,6 +567,26 @@ aplsmc_write_key(struct aplsmc_softc *sc, uint32_t key, void *data, size_t len) #ifndef SMALL_KERNEL +int64_t +aplsmc_convert_flt(uint32_t flt, int scale) +{ + int64_t mant; + int sign, exp; + + /* + * Convert floating-point to integer, trying to keep as much + * resolution as possible given the scaling factor. + */ + sign = (flt >> 31) ? -1 : 1; + exp = ((flt >> 23) & 0xff) - 127; + mant = (flt & 0x7fffff) | 0x800000; + mant *= scale; + if (exp < 23) + return sign * (mant >> (23 - exp)); + else + return sign * (mant << (exp - 23)); +} + void aplsmc_refresh_sensors(void *arg) { @@ -570,26 +615,11 @@ aplsmc_refresh_sensors(void *arg) value = (int64_t)ui16 * sensor->scale; } else if (strcmp(sensor->key_type, "flt ") == 0) { uint32_t flt; - int64_t mant; - int sign, exp; error = aplsmc_read_key(sc, key, &flt, sizeof(flt)); if (sensor->flags & APLSMC_BE) flt = betoh32(flt); - - /* - * Convert floating-point to integer, trying - * to keep as much resolution as possible - * given the scaling factor for this sensor. - */ - sign = (flt >> 31) ? -1 : 1; - exp = ((flt >> 23) & 0xff) - 127; - mant = (flt & 0x7fffff) | 0x800000; - mant *= sensor->scale; - if (exp < 23) - value = sign * (mant >> (23 - exp)); - else - value = sign * (mant << (exp - 23)); + value = aplsmc_convert_flt(flt, sensor->scale); } /* Apple reports temperatures in degC. */ diff --git a/sys/arch/arm64/dev/mainbus.c b/sys/arch/arm64/dev/mainbus.c index ebe9befdc..192e45c2f 100644 --- a/sys/arch/arm64/dev/mainbus.c +++ b/sys/arch/arm64/dev/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.25 2023/05/19 21:15:16 patrick Exp $ */ +/* $OpenBSD: mainbus.c,v 1.27 2023/07/19 21:52:55 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * Copyright (c) 2017 Mark Kettenis @@ -154,13 +154,11 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) mainbus_attach_apm(self); /* Scan the whole tree. */ - sc->sc_early = 1; - for (node = OF_child(sc->sc_node); node != 0; node = OF_peer(node)) - mainbus_attach_node(self, node, NULL); - + for (sc->sc_early = 2; sc->sc_early >= 0; sc->sc_early--) { + for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) + mainbus_attach_node(self, node, NULL); + } sc->sc_early = 0; - for (node = OF_child(sc->sc_node); node != 0; node = OF_peer(node)) - mainbus_attach_node(self, node, NULL); mainbus_attach_framebuffer(self); diff --git a/sys/arch/arm64/dev/simplebus.c b/sys/arch/arm64/dev/simplebus.c index e28a6a2a2..4bd468eaa 100644 --- a/sys/arch/arm64/dev/simplebus.c +++ b/sys/arch/arm64/dev/simplebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebus.c,v 1.16 2022/11/06 12:01:52 patrick Exp $ */ +/* $OpenBSD: simplebus.c,v 1.17 2023/07/19 20:26:11 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -140,13 +140,10 @@ simplebus_attach(struct device *parent, struct device *self, void *aux) } /* Scan the whole tree. */ - sc->sc_early = 1; - for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) - simplebus_attach_node(self, node); - - sc->sc_early = 0; - for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) - simplebus_attach_node(self, node); + for (sc->sc_early = 2; sc->sc_early >= 0; sc->sc_early--) { + for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) + simplebus_attach_node(self, node); + } } int diff --git a/sys/arch/arm64/include/cpu.h b/sys/arch/arm64/include/cpu.h index 9ca13c882..36d2d40ac 100644 --- a/sys/arch/arm64/include/cpu.h +++ b/sys/arch/arm64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.36 2023/06/10 19:30:48 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.37 2023/07/13 08:33:36 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn * @@ -154,6 +154,9 @@ struct cpu_info { volatile int ci_opp_max; uint32_t ci_cpu_supply; + u_long ci_prev_sleep; + u_long ci_last_itime; + #ifdef MULTIPROCESSOR struct srp_hazard ci_srp_hazards[SRP_HAZARD_NUM]; volatile int ci_flags; @@ -344,6 +347,11 @@ void cpu_startclock(void); int cpu_suspend_primary(void); void cpu_resume_secondary(struct cpu_info *); +extern void (*cpu_idle_cycle_fcn)(void); +extern void (*cpu_suspend_cycle_fcn)(void); + +void cpu_wfi(void); + void delay (unsigned); #define DELAY(x) delay(x) diff --git a/sys/arch/i386/conf/RAMDISK b/sys/arch/i386/conf/RAMDISK index c3da84608..9775b6a0c 100644 --- a/sys/arch/i386/conf/RAMDISK +++ b/sys/arch/i386/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.201 2021/02/16 00:03:54 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.202 2023/07/20 02:26:24 yasuoka Exp $ machine i386 maxusers 4 @@ -84,8 +84,8 @@ wskbd* at pckbd? mux 1 vga0 at isa? vga* at pci? pcdisplay0 at isa? # CGA, MDA, EGA, HGA -wsdisplay* at vga? -wsdisplay* at pcdisplay? +wsdisplay0 at vga? console 1 +wsdisplay0 at pcdisplay? console 1 com0 at isa? port 0x3f8 irq 4 # standard PC serial ports com1 at isa? port 0x2f8 irq 3 diff --git a/sys/arch/i386/conf/RAMDISK_CD b/sys/arch/i386/conf/RAMDISK_CD index 401c763e2..d9431f1d2 100644 --- a/sys/arch/i386/conf/RAMDISK_CD +++ b/sys/arch/i386/conf/RAMDISK_CD @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK_CD,v 1.252 2022/06/26 20:05:06 sthen Exp $ +# $OpenBSD: RAMDISK_CD,v 1.253 2023/07/20 02:26:24 yasuoka Exp $ machine i386 maxusers 4 @@ -124,8 +124,8 @@ wskbd* at pckbd? mux 1 vga0 at isa? vga* at pci? pcdisplay0 at isa? # CGA, MDA, EGA, HGA -wsdisplay* at vga? -wsdisplay* at pcdisplay? +wsdisplay0 at vga? console 1 +wsdisplay0 at pcdisplay? console 1 com0 at isa? port 0x3f8 irq 4 # standard PC serial ports com1 at isa? port 0x2f8 irq 3 diff --git a/sys/arch/i386/i386/db_memrw.c b/sys/arch/i386/i386/db_memrw.c index 3a39c698d..dc45265f9 100644 --- a/sys/arch/i386/i386/db_memrw.c +++ b/sys/arch/i386/i386/db_memrw.c @@ -128,7 +128,7 @@ db_write_text(vaddr_t addr, size_t size, char *data) */ pmap_update_pg(pgva); pmap_pte_setbits(addr, bits, PG_RW); - + } while (size != 0); } diff --git a/sys/arch/i386/i386/dkcsum.c b/sys/arch/i386/i386/dkcsum.c index 423eb9e69..534c674bd 100644 --- a/sys/arch/i386/i386/dkcsum.c +++ b/sys/arch/i386/i386/dkcsum.c @@ -171,7 +171,7 @@ dkcsumattach(void) #ifdef DEBUG printf("dkcsum: %s has no matching BIOS drive\n", dv->dv_xname); -#endif +#endif continue; } diff --git a/sys/arch/i386/i386/esm.c b/sys/arch/i386/i386/esm.c index 51535d0d1..f109f874e 100644 --- a/sys/arch/i386/i386/esm.c +++ b/sys/arch/i386/i386/esm.c @@ -1033,7 +1033,7 @@ esm_cmd(struct esm_softc *sc, void *cmd, size_t cmdlen, void *resp, /* Set host busy semaphore and clear doorbell */ ECTRLWR(sc, ESM2_TC_HOSTBUSY); ECTRLWR(sc, ESM2_TC_EC2HDB); - + /* Read response data from port */ ECTRLWR(sc, ESM2_TC_CLR_RPTR); for (i = 0; i < resplen; i++) { diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c index 972d3bc59..e4617ab62 100644 --- a/sys/arch/i386/i386/est.c +++ b/sys/arch/i386/i386/est.c @@ -1138,7 +1138,7 @@ est_init(struct cpu_info *ci, int vendor) * disable EST: - A lowest clock ratio of 0, which * seems to happen on all Pentium 4's that report EST. * - An equal highest and lowest clock ratio, which - * happens on at least the Core 2 Duo X6800, maybe on + * happens on at least the Core 2 Duo X6800, maybe on * newer models too. */ return; diff --git a/sys/arch/i386/i386/i686_mem.c b/sys/arch/i386/i386/i686_mem.c index 985062caa..42c0a88e1 100644 --- a/sys/arch/i386/i386/i686_mem.c +++ b/sys/arch/i386/i386/i686_mem.c @@ -135,7 +135,7 @@ mem_range_match(struct mem_range_softc *sc, struct mem_range_desc *mrd) { struct mem_range_desc *cand; int i; - + for (i = 0, cand = sc->mr_desc; i < sc->mr_ndesc; i++, cand++) if ((cand->mr_base == mrd->mr_base) && (cand->mr_len == mrd->mr_len)) @@ -159,7 +159,7 @@ mrfetch(struct mem_range_softc *sc) /* We should never be fetching MTRRs from an AP */ KASSERT(CPU_IS_PRIMARY(curcpu())); - + /* Get fixed-range MTRRs, if the CPU supports them */ if (sc->mr_cap & MR_FIXMTRR) { msr = MSR_MTRRfix64K_00000; @@ -242,9 +242,9 @@ int mtrrtype(u_int64_t flags) { int i; - + flags &= MDF_ATTRMASK; - + for (i = 0; i < nitems(mtrrtomrt); i++) { if (mtrrtomrt[i] == MDF_UNKNOWN) continue; @@ -295,9 +295,9 @@ mrstoreone(struct mem_range_softc *sc) u_int64_t msrv; int i, j, msr; u_int cr4save; - + mrd = sc->mr_desc; - + cr4save = rcr4(); /* save cr4 */ if (cr4save & CR4_PGE) lcr4(cr4save & ~CR4_PGE); @@ -306,7 +306,7 @@ mrstoreone(struct mem_range_softc *sc) wbinvd(); lcr0((rcr0() & ~CR0_NW) | CR0_CD); wrmsr(MSR_MTRRdefType, rdmsr(MSR_MTRRdefType) & ~MTRRdefType_ENABLE); - + /* Set fixed-range MTRRs */ if (sc->mr_cap & MR_FIXMTRR) { msr = MSR_MTRRfix64K_00000; @@ -340,7 +340,7 @@ mrstoreone(struct mem_range_softc *sc) mrd += 8; } } - + /* Set remainder which must be variable MTRRs */ msr = MSR_MTRRvarBase; for (; (mrd - sc->mr_desc) < sc->mr_ndesc; msr += 2, mrd++) { @@ -350,8 +350,8 @@ mrstoreone(struct mem_range_softc *sc) } else msrv = 0; - wrmsr(msr, msrv); - + wrmsr(msr, msrv); + /* mask/active register */ if (mrd->mr_flags & MDF_ACTIVE) { msrv = 0x800 | (~(mrd->mr_len - 1) & mtrrmask); @@ -375,7 +375,7 @@ mtrrfixsearch(struct mem_range_softc *sc, u_int64_t addr) { struct mem_range_desc *mrd; int i; - + for (i = 0, mrd = sc->mr_desc; i < (MTRR_N64K + MTRR_N16K + MTRR_N4K); i++, mrd++) if ((addr >= mrd->mr_base) && (addr < (mrd->mr_base + mrd->mr_len))) return(mrd); @@ -399,7 +399,7 @@ mrsetlow(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) if (((first_md = mtrrfixsearch(sc, mrd->mr_base)) == NULL) || ((last_md = mtrrfixsearch(sc, mrd->mr_base + mrd->mr_len - 1)) == NULL)) return(EINVAL); - + /* check we aren't doing something risky */ if (!(mrd->mr_flags & MDF_FORCE)) for (curr_md = first_md; curr_md <= last_md; curr_md++) { @@ -412,7 +412,7 @@ mrsetlow(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) curr_md->mr_flags = mrcopyflags(curr_md->mr_flags & ~MDF_FIRMWARE, mrd->mr_flags); bcopy(mrd->mr_owner, curr_md->mr_owner, sizeof(mrd->mr_owner)); } - + return(0); } @@ -464,7 +464,7 @@ mrsetvariable(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) /* got somewhere to put it? */ if (free_md == NULL) return(ENOSPC); - + /* Set up new descriptor */ free_md->mr_base = mrd->mr_base; free_md->mr_len = mrd->mr_len; @@ -488,7 +488,7 @@ mrset(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) if (!mrvalid(mrd->mr_base, mrd->mr_len) || mtrrtype(mrd->mr_flags) == -1) return(EINVAL); - + /* are the "low memory" conditions applicable? */ if ((sc->mr_cap & MR_FIXMTRR) && ((mrd->mr_base + mrd->mr_len) <= FIXTOP)) { @@ -500,7 +500,7 @@ mrset(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) return(error); } break; - + case MEMRANGE_SET_REMOVE: if ((targ = mem_range_match(sc, mrd)) == NULL) return(ENOENT); @@ -509,11 +509,11 @@ mrset(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) targ->mr_flags &= ~MDF_ACTIVE; targ->mr_owner[0] = 0; break; - + default: return(EOPNOTSUPP); } - + /* update the hardware */ mrstore(sc); return(0); @@ -533,7 +533,7 @@ mrinit(struct mem_range_softc *sc) mtrrcap = rdmsr(MSR_MTRRcap); mtrrdef = rdmsr(MSR_MTRRdefType); - + /* For now, bail out if MTRRs are not enabled */ if (!(mtrrdef & MTRRdefType_ENABLE)) { printf("mtrr: CPU supports MTRRs but not enabled by BIOS\n"); @@ -541,9 +541,9 @@ mrinit(struct mem_range_softc *sc) } nmdesc = mtrrcap & 0xff; printf("mtrr: Pentium Pro MTRR support, %d var ranges", nmdesc); - + /* If fixed MTRRs supported and enabled */ - if ((mtrrcap & MTRRcap_FIXED) && + if ((mtrrcap & MTRRcap_FIXED) && (mtrrdef & MTRRdefType_FIXED_ENABLE)) { sc->mr_cap = MR_FIXMTRR; nmdesc += MTRR_N64K + MTRR_N16K + MTRR_N4K; @@ -551,13 +551,13 @@ mrinit(struct mem_range_softc *sc) } printf("\n"); - + sc->mr_desc = mallocarray(nmdesc, sizeof(struct mem_range_desc), M_MEMDESC, M_WAITOK|M_ZERO); sc->mr_ndesc = nmdesc; - + mrd = sc->mr_desc; - + /* Populate the fixed MTRR entries' base/length */ if (sc->mr_cap & MR_FIXMTRR) { for (i = 0; i < MTRR_N64K; i++, mrd++) { @@ -578,7 +578,7 @@ mrinit(struct mem_range_softc *sc) mrd->mr_flags = MDF_FIXBASE | MDF_FIXLEN | MDF_FIXACTIVE; } } - + /* * Fetch maximum physical address size supported by the * processor as supported by CPUID leaf function 0x80000008. diff --git a/sys/arch/i386/i386/ioapic.c b/sys/arch/i386/i386/ioapic.c index 33e617cb2..0673e2e14 100644 --- a/sys/arch/i386/i386/ioapic.c +++ b/sys/arch/i386/i386/ioapic.c @@ -137,7 +137,7 @@ static __inline u_int32_t ioapic_read_ul(struct ioapic_softc *sc,int regid) { u_int32_t val; - + *(sc->sc_reg) = regid; val = *sc->sc_data; @@ -493,7 +493,7 @@ apic_vectorset(struct ioapic_softc *sc, int pin, int minlevel, int maxlevel) { struct ioapic_pin *pp = &sc->sc_pins[pin]; int nvector, ovector = pp->ip_vector; - + if (maxlevel == 0) { /* no vector needed. */ pp->ip_minlevel = 0xff; /* XXX magic */ @@ -593,7 +593,7 @@ ioapic_enable(void) for (p = 0; p < sc->sc_apic_sz; p++) { maxlevel = 0; /* magic */ minlevel = 0xff; /* magic */ - + for (q = sc->sc_pins[p].ip_handler; q != NULL; q = q->ih_next) { if (q->ih_level > maxlevel) diff --git a/sys/arch/i386/i386/ipifuncs.c b/sys/arch/i386/i386/ipifuncs.c index 17a00c22e..c4c834c47 100644 --- a/sys/arch/i386/i386/ipifuncs.c +++ b/sys/arch/i386/i386/ipifuncs.c @@ -190,7 +190,7 @@ i386_broadcast_ipi(int ipimask) if (!count) return; - i386_ipi(LAPIC_IPI_VECTOR, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED); + i386_ipi(LAPIC_IPI_VECTOR, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED); } void diff --git a/sys/arch/i386/i386/k6_mem.c b/sys/arch/i386/i386/k6_mem.c index 6aef4adb7..db0dbbfb3 100644 --- a/sys/arch/i386/i386/k6_mem.c +++ b/sys/arch/i386/i386/k6_mem.c @@ -108,7 +108,7 @@ k6_mrinit(struct mem_range_softc *sc) reg = rdmsr(UWCCR); for (d = 0; d < sc->mr_ndesc; d++) { u_int32_t one = (reg & (0xffffffff << (32 * d))) >> (32 * d); - + k6_reg_get(one, addr, mask, wc, uc); sc->mr_desc[d].mr_base = addr; sc->mr_desc[d].mr_len = ffs(mask) << 17; @@ -117,7 +117,7 @@ k6_mrinit(struct mem_range_softc *sc) if (uc) sc->mr_desc[d].mr_flags |= MDF_UNCACHEABLE; } - + printf("mtrr: K6-family MTRR support (%d registers)\n", sc->mr_ndesc); } @@ -160,7 +160,7 @@ k6_mrset(struct mem_range_softc *sc, struct mem_range_desc *desc, int *arg) } out: - + s = intr_disable(); wbinvd(); reg = rdmsr(UWCCR); diff --git a/sys/arch/i386/i386/lapic.c b/sys/arch/i386/i386/lapic.c index fae8f71cb..7959c0edb 100644 --- a/sys/arch/i386/i386/lapic.c +++ b/sys/arch/i386/i386/lapic.c @@ -151,7 +151,7 @@ lapic_set_lvt(void) * the local APIC timer dead, so we disable it by reading * the Interrupt Pending Message register and clearing both * C1eOnCmpHalt (bit 28) and SmiOnCmpHalt (bit 27). - * + * * Reference: * "BIOS and Kernel Developer's Guide for AMD NPT * Family 0Fh Processors" diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 14949a6b9..483d4bfd9 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1121,7 +1121,7 @@ cyrix3_cpu_setup(struct cpu_info *ci) /* * C3 Nehemiah & later: fall through. */ - + case 10: /* C7-M Type A */ case 13: /* C7-M Type D */ case 15: /* Nano */ @@ -1770,7 +1770,7 @@ identifycpu(struct cpu_info *ci) * with eax 0x01 */ - cpuid(0x01, regs); + cpuid(0x01, regs); ci->ci_cflushsz = ((regs[1] >> 8) & 0xff) * 8; } @@ -2263,7 +2263,7 @@ p3_get_bus_clock(struct cpu_info *ci) goto print_msr; } break; - default: + default: /* no FSB on modern Intel processors */ break; } @@ -3170,7 +3170,7 @@ init386(paddr_t first_avail) if (bios_memmap == NULL) panic("no BIOS memory map supplied"); #endif - + /* * account all the memory passed in the map from /boot * calculate avail_end and count the physmem. diff --git a/sys/arch/i386/i386/mainbus.c b/sys/arch/i386/i386/mainbus.c index 62c6ca3e9..1f4329e11 100644 --- a/sys/arch/i386/i386/mainbus.c +++ b/sys/arch/i386/i386/mainbus.c @@ -231,7 +231,7 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) #if NPCI > 0 if (pci_mode_detect() != 0) { pci_init_extents(); - + bzero(&mba.mba_pba, sizeof(mba.mba_pba)); mba.mba_pba.pba_busname = "pci"; mba.mba_pba.pba_iot = I386_BUS_SPACE_IO; diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c index db316bd67..5b7245c75 100644 --- a/sys/arch/i386/i386/mem.c +++ b/sys/arch/i386/i386/mem.c @@ -236,7 +236,7 @@ mmmmap(dev_t dev, off_t off, int prot) default: return -1; } - + #endif default: return -1; @@ -276,7 +276,7 @@ mem_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) int nd, error = 0; struct mem_range_op *mo = (struct mem_range_op *)data; struct mem_range_desc *md; - + /* is this for us? */ if ((cmd != MEMRANGE_GET) && (cmd != MEMRANGE_SET)) @@ -306,7 +306,7 @@ mem_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) } mo->mo_arg[0] = nd; break; - + case MEMRANGE_SET: md = malloc(sizeof(struct mem_range_desc), M_MEMDESC, M_WAITOK); error = copyin(mo->mo_desc, md, sizeof(struct mem_range_desc)); diff --git a/sys/arch/i386/i386/mptramp.s b/sys/arch/i386/i386/mptramp.s index 95e27cf54..3865dde97 100644 --- a/sys/arch/i386/i386/mptramp.s +++ b/sys/arch/i386/i386/mptramp.s @@ -151,7 +151,7 @@ _TRMP_LABEL(.Lmp_startup) movl %cr4,%eax orl $CR4_PAE,%eax movl %eax, %cr4 - + movl $MSR_EFER,%ecx rdmsr orl $EFER_NXE, %eax diff --git a/sys/arch/i386/i386/mtrr.c b/sys/arch/i386/i386/mtrr.c index ebfa559c1..9ad134d79 100644 --- a/sys/arch/i386/i386/mtrr.c +++ b/sys/arch/i386/i386/mtrr.c @@ -51,7 +51,7 @@ mem_range_attach(void) (model == 0x8 && step > 0x7))) { mem_range_softc.mr_op = &k6_mrops; - + /* Try for i686 MTRRs */ } else if (((strcmp(cpu_vendor, "GenuineIntel") == 0) || (strcmp(cpu_vendor, "CentaurHauls") == 0) || diff --git a/sys/arch/i386/i386/pctr.c b/sys/arch/i386/i386/pctr.c index 29be98fd7..4378b6d67 100644 --- a/sys/arch/i386/i386/pctr.c +++ b/sys/arch/i386/i386/pctr.c @@ -177,7 +177,7 @@ pctrioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) case PCIOCRD: { struct pctrst *st = (struct pctrst *)data; - + if (usepctr) pctrrd(st); else if (usep5ctr) diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index 8c66ae975..ebc82787e 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -577,7 +577,7 @@ pmap_exec_account(struct pmap *pm, vaddr_t va, if ((opte ^ npte) & PG_X) pmap_tlb_shootpage(pm, va); - + if (cpu_pae) return; @@ -1437,7 +1437,7 @@ pmap_destroy(struct pmap *pmap) return; #ifdef MULTIPROCESSOR - pmap_tlb_droppmap(pmap); + pmap_tlb_droppmap(pmap); #endif mtx_enter(&pmaps_lock); @@ -1639,7 +1639,7 @@ pmap_flush_cache(vaddr_t addr, vsize_t len) wbinvd_on_all_cpus(); return; } - + mfence(); for (i = addr; i < addr + len; i += curcpu()->ci_cflushsz) clflush(i); @@ -1660,7 +1660,7 @@ pmap_flush_page(paddr_t pa) if (cpu_pae) { pmap_flush_page_pae(pa); return; - } + } pte = PTESLEW(flsh_pte, id); va = VASLEW(pmap_flshp, id); @@ -2864,7 +2864,7 @@ pmap_tlb_shootrange(struct pmap *pm, vaddr_t sva, vaddr_t eva) vaddr_t va; for (va = sva; va < eva; va += PAGE_SIZE) - pmap_update_pg(va); + pmap_update_pg(va); } void diff --git a/sys/arch/i386/i386/powernow-k7.c b/sys/arch/i386/i386/powernow-k7.c index e5626b0c5..a7b1a6aa7 100644 --- a/sys/arch/i386/i386/powernow-k7.c +++ b/sys/arch/i386/i386/powernow-k7.c @@ -359,9 +359,9 @@ k7pnow_acpi_init(struct k7pnow_cpu_state *cstate, uint64_t status) return 0; curs = k7pnow_acpi_states(cstate, pss, cstate->n_states, status); - /* + /* * XXX: Some BIOS supplied _PSS implementations have the wrong - * maximum frequency, if we encounter one of these punt and + * maximum frequency, if we encounter one of these punt and * hope the legacy tables have correct values. */ mfid = PN7_STA_MFID(status); diff --git a/sys/arch/i386/i386/process_machdep.c b/sys/arch/i386/i386/process_machdep.c index 65a9e0c0e..54924ed95 100644 --- a/sys/arch/i386/i386/process_machdep.c +++ b/sys/arch/i386/i386/process_machdep.c @@ -344,7 +344,7 @@ process_sstep(struct proc *p, int sstep) tf->tf_eflags |= PSL_T; else tf->tf_eflags &= ~PSL_T; - + return (0); } diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index ccaf9fc2d..8ac79e2cb 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -329,7 +329,7 @@ viac3_crypto_swauth(struct cryptop *crp, struct cryptodesc *crd, type = CRYPTO_BUF_MBUF; else type= CRYPTO_BUF_IOV; - + return (swcr_authcompute(crp, crd, sw, buf, type)); } diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 10f5f3e08..34d2a625f 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -84,8 +84,8 @@ struct cpu_info { struct schedstate_percpu ci_schedstate; /* scheduler state */ struct cpu_info *ci_next; /* next cpu */ - /* - * Public members. + /* + * Public members. */ struct proc *ci_curproc; /* current owner of the processor */ cpuid_t ci_cpuid; /* our CPU ID */ @@ -178,7 +178,7 @@ struct cpu_info { * roles (mostly relating to hardclock handling); we distinguish * between the processor which booted us, and the processor currently * holding the "primary" role just to give us the flexibility later to - * change primaries should we be sufficiently twisted. + * change primaries should we be sufficiently twisted. */ #define CPUF_BSP 0x0001 /* CPU is the original BSP */ @@ -473,7 +473,7 @@ void mp_setperf_init(void); int cpu_paenable(void *); #endif /* _KERNEL */ -/* +/* * CTL_MACHDEP definitions. */ #define CPU_CONSDEV 1 /* dev_t: console terminal device */ diff --git a/sys/arch/i386/include/cpufunc.h b/sys/arch/i386/include/cpufunc.h index 098b5982d..5da908f71 100644 --- a/sys/arch/i386/include/cpufunc.h +++ b/sys/arch/i386/include/cpufunc.h @@ -65,11 +65,11 @@ static __inline void wrmsr(u_int, u_int64_t); static __inline u_int64_t rdmsr(u_int); static __inline void breakpoint(void); -static __inline void +static __inline void invlpg(u_int addr) -{ +{ __asm volatile("invlpg (%0)" : : "r" (addr) : "memory"); -} +} static __inline void lidt(void *p) @@ -257,14 +257,14 @@ mwait(u_long extensions, u_int hints) __asm volatile("mwait" : : "a" (hints), "c" (extensions)); } -/* +/* * Some of the undocumented AMD64 MSRs need a 'passcode' to access. * * See LinuxBIOSv2: src/cpu/amd/model_fxx/model_fxx_init.c */ #define OPTERON_MSR_PASSCODE 0x9c5a203a - + static __inline u_int64_t rdmsr_locked(u_int msr, u_int code) { diff --git a/sys/arch/i386/include/cpuvar.h b/sys/arch/i386/include/cpuvar.h index 1e4cca64b..dbb3e0dfa 100644 --- a/sys/arch/i386/include/cpuvar.h +++ b/sys/arch/i386/include/cpuvar.h @@ -49,7 +49,7 @@ * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/sys/arch/i386/include/db_machdep.h b/sys/arch/i386/include/db_machdep.h index 0d8e917cf..f60c82b22 100644 --- a/sys/arch/i386/include/db_machdep.h +++ b/sys/arch/i386/include/db_machdep.h @@ -1,28 +1,28 @@ /* $OpenBSD: db_machdep.h,v 1.30 2021/08/30 08:11:12 jasper Exp $ */ /* $NetBSD: db_machdep.h,v 1.9 1996/05/03 19:23:59 christos Exp $ */ -/* +/* * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ diff --git a/sys/arch/i386/include/i82093reg.h b/sys/arch/i386/include/i82093reg.h index a4b9451f3..4ed3c8575 100644 --- a/sys/arch/i386/include/i82093reg.h +++ b/sys/arch/i386/include/i82093reg.h @@ -59,7 +59,7 @@ #define IOAPIC_ID_MASK 0x0f000000 /* Version, and maximum interrupt pin number. */ - + #define IOAPIC_VER 0x01 #define IOAPIC_VER_SHIFT 0 diff --git a/sys/arch/i386/include/i82093var.h b/sys/arch/i386/include/i82093var.h index 5439da32d..9d14bb40d 100644 --- a/sys/arch/i386/include/i82093var.h +++ b/sys/arch/i386/include/i82093var.h @@ -37,9 +37,9 @@ #include -struct ioapic_pin +struct ioapic_pin { - struct intrhand *ip_handler; + struct intrhand *ip_handler; struct ioapic_pin *ip_next; /* next pin on this vector */ struct mp_intr_map *ip_map; int ip_vector; /* IDT vector */ @@ -60,7 +60,7 @@ struct ioapic_softc { volatile u_int32_t *sc_reg; /* KVA of ioapic addr */ volatile u_int32_t *sc_data; /* KVA of ioapic data */ struct ioapic_pin *sc_pins; /* sc_apic_sz entries */ -}; +}; /* * MP: intr_handle_t is bitfielded. @@ -82,7 +82,7 @@ struct ioapic_softc { #define APIC_IRQ_PIN(x) ((x & APIC_INT_PIN_MASK) >> APIC_INT_PIN_SHIFT) void *apic_intr_establish(int, int, int, int (*)(void *), void *, - const char *); + const char *); void apic_intr_disestablish(void *); void ioapic_print_redir(struct ioapic_softc *, char *, int); diff --git a/sys/arch/i386/include/ieeefp.h b/sys/arch/i386/include/ieeefp.h index 7e5df84f5..4218e8cda 100644 --- a/sys/arch/i386/include/ieeefp.h +++ b/sys/arch/i386/include/ieeefp.h @@ -1,6 +1,6 @@ /* $OpenBSD: ieeefp.h,v 1.3 2011/03/23 16:54:35 pirofti Exp $ */ -/* +/* * Written by J.T. Conklin, Apr 6, 1995 * Public domain. */ diff --git a/sys/arch/i386/include/intrdefs.h b/sys/arch/i386/include/intrdefs.h index 8a2716050..8b0094475 100644 --- a/sys/arch/i386/include/intrdefs.h +++ b/sys/arch/i386/include/intrdefs.h @@ -41,7 +41,7 @@ * XXX in various arrays of our implementation. We are hoping that * XXX the context will provide enough information to not make this * XXX sloppy naming a real problem. - * + * * There are tty, network and disk drivers that use free() at interrupt * time, so imp > (tty | net | bio). * diff --git a/sys/arch/i386/include/mpbiosreg.h b/sys/arch/i386/include/mpbiosreg.h index c84a66ecb..a97938b3f 100644 --- a/sys/arch/i386/include/mpbiosreg.h +++ b/sys/arch/i386/include/mpbiosreg.h @@ -81,7 +81,7 @@ struct mpbios_fps { u_int32_t signature; /* string defined by the Intel MP Spec as identifying the MP table */ #define MP_FP_SIG 0x5f504d5f /* _MP_ */ - + u_int32_t pap; u_int8_t length; u_int8_t spec_rev; @@ -98,7 +98,7 @@ struct mpbios_fps { struct mpbios_cth { u_int32_t signature; #define MP_CT_SIG 0x504d4350 /* PCMP */ - + u_int16_t base_len; u_int8_t spec_rev; u_int8_t checksum; diff --git a/sys/arch/i386/include/mpbiosvar.h b/sys/arch/i386/include/mpbiosvar.h index b22fbd823..1528906aa 100644 --- a/sys/arch/i386/include/mpbiosvar.h +++ b/sys/arch/i386/include/mpbiosvar.h @@ -43,7 +43,7 @@ #include -struct mp_bus +struct mp_bus { char *mb_name; /* XXX bus name */ int mb_idx; /* XXX bus index */ diff --git a/sys/arch/i386/include/pic.h b/sys/arch/i386/include/pic.h index 3e5b2d9e0..f7c7a7f4f 100644 --- a/sys/arch/i386/include/pic.h +++ b/sys/arch/i386/include/pic.h @@ -9,7 +9,7 @@ struct cpu_info; -/* +/* * Structure common to all PIC softcs */ struct pic { diff --git a/sys/arch/i386/include/pmap.h b/sys/arch/i386/include/pmap.h index 7c2f8f4c9..f552c7c5b 100644 --- a/sys/arch/i386/include/pmap.h +++ b/sys/arch/i386/include/pmap.h @@ -349,7 +349,7 @@ vaddr_t pmap_tmpmap_pa_pae(paddr_t); void pmap_tmpunmap_pa_pae(void); -/* +/* * functions for flushing the cache for vaddrs and pages. * these functions are not part of the MI pmap interface and thus * should not be used as such. diff --git a/sys/arch/i386/include/profile.h b/sys/arch/i386/include/profile.h index 6bba09b42..20621495c 100644 --- a/sys/arch/i386/include/profile.h +++ b/sys/arch/i386/include/profile.h @@ -68,7 +68,7 @@ mcount(void) \ #ifdef _KERNEL /* * We inline the code that splhigh and splx would do here as otherwise we would - * call recursively into mcount() as machdep.c is compiled with -pg on a + * call recursively into mcount() as machdep.c is compiled with -pg on a * profiling build. */ #define MCOUNT_ENTER _SPLRAISE(s, IPL_HIGH); __splbarrier() diff --git a/sys/arch/i386/include/psl.h b/sys/arch/i386/include/psl.h index 7293e2a5d..e134e978b 100644 --- a/sys/arch/i386/include/psl.h +++ b/sys/arch/i386/include/psl.h @@ -94,5 +94,5 @@ extern int intr_shared_edge; /* This system has shared edge interrupts */ #endif /* _LOCORE */ #endif /* _KERNEL */ - + #endif /* !_MACHINE_PSL_H_ */ diff --git a/sys/arch/i386/include/reloc.h b/sys/arch/i386/include/reloc.h index c183f5475..312923a39 100644 --- a/sys/arch/i386/include/reloc.h +++ b/sys/arch/i386/include/reloc.h @@ -41,10 +41,10 @@ #define RELOC_GOTOFF 9 /* 32 bit offset to GOT */ #define RELOC_GOTPC 10 /* 32 bit PC relative offset to GOT */ #define RELOC_TLS_TPOFF 14 /* negative offset in static TLS block */ -#define RELOC_16 20 -#define RELOC_PC16 21 -#define RELOC_8 22 -#define RELOC_PC8 23 +#define RELOC_16 20 +#define RELOC_PC16 21 +#define RELOC_8 22 +#define RELOC_PC8 23 #define RELOC_TLS_DTPMOD32 35 /* ID of module containing symbol */ #define RELOC_TLS_DTPOFF32 36 /* Offset in TLS block */ #define RELOC_TLS_TPOFF32 37 /* Offset in static TLS block */ diff --git a/sys/arch/i386/include/segments.h b/sys/arch/i386/include/segments.h index 646c7b3d5..5bf685845 100644 --- a/sys/arch/i386/include/segments.h +++ b/sys/arch/i386/include/segments.h @@ -50,11 +50,11 @@ */ #define ISPL(s) ((s) & SEL_RPL) /* what is the priority level of a selector */ -#define SEL_KPL 0 /* kernel privilege level */ -#define SEL_UPL 3 /* user privilege level */ +#define SEL_KPL 0 /* kernel privilege level */ +#define SEL_UPL 3 /* user privilege level */ #define SEL_RPL 3 /* requester's privilege level mask */ #define ISLDT(s) ((s) & SEL_LDT) /* is it local or global */ -#define SEL_LDT 4 /* local descriptor table */ +#define SEL_LDT 4 /* local descriptor table */ #define IDXSEL(s) (((s) >> 3) & 0x1fff) /* index of selector */ #define GSEL(s,r) (((s) << 3) | r) /* a global selector */ #define LSEL(s,r) (((s) << 3) | r | SEL_LDT) /* a local selector */ diff --git a/sys/arch/i386/include/specialreg.h b/sys/arch/i386/include/specialreg.h index 22ee7abba..39ab38348 100644 --- a/sys/arch/i386/include/specialreg.h +++ b/sys/arch/i386/include/specialreg.h @@ -558,7 +558,7 @@ * NCRx+0: A31-A24 of starting address * NCRx+1: A23-A16 of starting address * NCRx+2: A15-A12 of starting address | NCR_SIZE_xx. - * + * * The non-cacheable region's starting address must be aligned to the * size indicated by the NCR_SIZE_xx field. */ diff --git a/sys/arch/i386/isa/ahc_isa.c b/sys/arch/i386/isa/ahc_isa.c index 1fb9dbf82..3594c6911 100644 --- a/sys/arch/i386/isa/ahc_isa.c +++ b/sys/arch/i386/isa/ahc_isa.c @@ -150,7 +150,7 @@ ahc_isa_irq(bus_space_tag_t iot, bus_space_handle_t ioh) int irq; u_char intdef; u_char hcntrl; - + /* Pause the card preserving the IRQ type */ hcntrl = bus_space_read_1(iot, ioh, HCNTRL) & IRQMS; bus_space_write_1(iot, ioh, HCNTRL, hcntrl | PAUSE); @@ -284,7 +284,7 @@ ahc_isa_match(struct isa_attach_args *ia, bus_addr_t iobase) */ int ahc_isa_probe(struct device *parent, void *match, void *aux) -{ +{ struct isa_attach_args *ia = aux; struct ahc_isa_slot *as; @@ -341,15 +341,15 @@ ahc_isa_attach(struct device *parent, struct device *self, void *aux) char idstring[EISA_IDSTRINGLEN]; const char *model; u_int intdef; - + ahc_set_name(ahc, ahc->sc_dev.dv_xname); ahc_set_unit(ahc, ahc->sc_dev.dv_unit); - + /* set dma tags */ ahc->parent_dmat = ia->ia_dmat; - - ahc->chip = AHC_VL; /* We are a VL Bus Controller */ - + + ahc->chip = AHC_VL; /* We are a VL Bus Controller */ + if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh)) panic("ahc_isa_attach: can't map slot i/o addresses"); if (!ahc_isa_idstring(iot, ioh, idstring)) @@ -365,13 +365,13 @@ ahc_isa_attach(struct device *parent, struct device *self, void *aux) panic("ahc_isa_attach: Unknown device type %s", idstring); } printf(": %s\n", model); - + ahc->channel = 'A'; ahc->chip = AHC_AIC7770; ahc->features = AHC_AIC7770_FE; ahc->bugs |= AHC_TMODE_WIDEODD_BUG; ahc->flags |= AHC_PAGESCBS; - + /* set tag and handle */ ahc->tag = iot; ahc->bsh = ioh; @@ -387,26 +387,26 @@ ahc_isa_attach(struct device *parent, struct device *self, void *aux) if (ahc_reset(ahc, /*reinit*/FALSE) != 0) return; - + /* See if we are edge triggered */ intdef = ahc_inb(ahc, INTDEF); if ((intdef & EDGE_TRIG) != 0) ahc->flags |= AHC_EDGE_INTERRUPT; /* - * Now that we know we own the resources we need, do the + * Now that we know we own the resources we need, do the * card initialization. */ aha2840_load_seeprom(ahc); - /* + /* * See if we have a Rev E or higher aic7770. Anything below a * Rev E will have a R/O autoflush disable configuration bit. * It's still not clear exactly what is different about the Rev E. * We think it allows 8 bit entries in the QOUTFIFO to support * "paging" SCBs so you can have more than 4 commands active at * once. - */ + */ { char *id_string; u_char sblkctl; @@ -448,7 +448,7 @@ ahc_isa_attach(struct device *parent, struct device *self, void *aux) ahc_free(ahc); return; } - + /* * Link this softc in with all other ahc instances. */ @@ -474,7 +474,7 @@ ahc_isa_attach(struct device *parent, struct device *self, void *aux) } ahc_intr_enable(ahc, TRUE); - + /* Attach sub-devices - always succeeds */ ahc_attach(ahc); } @@ -496,7 +496,7 @@ aha2840_load_seeprom(struct ahc_softc *ahc) sd.sd_regsize = 1; sd.sd_control_offset = SEECTL_2840; sd.sd_status_offset = STATUS_2840; - sd.sd_dataout_offset = STATUS_2840; + sd.sd_dataout_offset = STATUS_2840; sd.sd_chip = C46; sd.sd_MS = 0; sd.sd_RDY = EEPROM_TF; @@ -508,7 +508,7 @@ aha2840_load_seeprom(struct ahc_softc *ahc) if (bootverbose) printf("%s: Reading SEEPROM...", ahc_name(ahc)); have_seeprom = read_seeprom(&sd, - (u_int16_t *)&sc, + (u_int16_t *)&sc, /*start_addr*/0, sizeof(sc)/2); @@ -565,7 +565,7 @@ aha2840_load_seeprom(struct ahc_softc *ahc) if (sc.adapter_control & CFRESETB) scsi_conf |= RESET_SCSI; - if (sc.bios_control & CF284XEXTEND) + if (sc.bios_control & CF284XEXTEND) ahc->flags |= AHC_EXTENDED_TRANS_A; /* Set SCSICONF info */ ahc_outb(ahc, SCSICONF, scsi_conf); diff --git a/sys/arch/i386/isa/clock.c b/sys/arch/i386/isa/clock.c index 4c3f40227..c449323e7 100644 --- a/sys/arch/i386/isa/clock.c +++ b/sys/arch/i386/isa/clock.c @@ -182,7 +182,7 @@ startclocks(void) /* Check diagnostic status */ if ((s = mc146818_read(NULL, NVRAM_DIAG)) != 0) /* XXX softc */ - printf("RTC BIOS diagnostic error %b\n", (unsigned int) s, + printf("RTC BIOS diagnostic error %b\n", (unsigned int) s, NVRAM_DIAG_BITS); } @@ -578,7 +578,7 @@ rtcgettime(struct todr_chip_handle *handle, struct timeval *tv) mc_todregs rtclk; struct clock_ymdhms dt; int s; - + s = splclock(); if (rtcget(&rtclk)) { splx(s); diff --git a/sys/arch/i386/isa/isa_machdep.c b/sys/arch/i386/isa/isa_machdep.c index d145455cf..37da2f0aa 100644 --- a/sys/arch/i386/isa/isa_machdep.c +++ b/sys/arch/i386/isa/isa_machdep.c @@ -169,7 +169,7 @@ isa_defaultirq(void) for (i = 0; i < ICU_LEN; i++) setgate(&idt[ICU_OFFSET + i], IDTVEC(intr)[i], 0, SDT_SYS386IGT, SEL_KPL, GICODE_SEL); - + /* initialize 8259's */ outb(IO_ICU1, 0x11); /* reset; program device, four bytes */ outb(IO_ICU1+1, ICU_OFFSET); /* starting at this vector index */ @@ -783,7 +783,7 @@ _isa_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, cookie->id_origbuflen = buflen; error = _bus_dmamap_load(t, map, cookie->id_bouncebuf, buflen, p, flags); - + if (error) { /* * Free the bounce pages, unless our resources @@ -799,7 +799,7 @@ _isa_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, /* * Just use the generic load function. */ - error = _bus_dmamap_load(t, map, buf, buflen, p, flags); + error = _bus_dmamap_load(t, map, buf, buflen, p, flags); } return (error); diff --git a/sys/arch/i386/isa/lms.c b/sys/arch/i386/isa/lms.c index 79159b04f..a7a4a9213 100644 --- a/sys/arch/i386/isa/lms.c +++ b/sys/arch/i386/isa/lms.c @@ -82,7 +82,7 @@ lmsprobe(struct device *parent, void *match, void *aux) bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; int rv; - + /* Disallow wildcarded i/o base. */ if (ia->ia_iobase == IOBASEUNK) return 0; diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c index 5e354d5d6..0cd2530a7 100644 --- a/sys/arch/i386/isa/npx.c +++ b/sys/arch/i386/isa/npx.c @@ -217,7 +217,7 @@ npxprobe1(struct isa_attach_args *ia) /* * Good, now check for a proper control word. */ - control = 0x5a5a; + control = 0x5a5a; fnstcw(&control); if ((control & 0x1f3f) == 0x033f) { /* diff --git a/sys/arch/i386/pci/ali1543.c b/sys/arch/i386/pci/ali1543.c index 977833c4c..a05c4b0a9 100644 --- a/sys/arch/i386/pci/ali1543.c +++ b/sys/arch/i386/pci/ali1543.c @@ -71,18 +71,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* HAYAKAWA Koichi wrote ALi 1543 PCI ICU code basing on VIA82C586 driver */ diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c index 2b9f39cb2..298c0c6c4 100644 --- a/sys/arch/i386/pci/glxsb.c +++ b/sys/arch/i386/pci/glxsb.c @@ -167,7 +167,7 @@ struct glxsb_softc { struct glxsb_session *sc_sessions; #endif /* CRYPTO */ - uint64_t save_gld_msr; + uint64_t save_gld_msr; }; int glxsb_match(struct device *, void *, void *); @@ -624,7 +624,7 @@ glxsb_crypto_swauth(struct cryptop *crp, struct cryptodesc *crd, type = CRYPTO_BUF_MBUF; else type = CRYPTO_BUF_IOV; - + return (swcr_authcompute(crp, crd, sw, buf, type)); } @@ -638,7 +638,7 @@ glxsb_crypto_swenc(struct cryptop *crp, struct cryptodesc *crd, type = CRYPTO_BUF_MBUF; else type = CRYPTO_BUF_IOV; - + return (swcr_encdec(crd, sw, buf, type)); } diff --git a/sys/arch/i386/pci/ichpcib.c b/sys/arch/i386/pci/ichpcib.c index 1524d56d1..352f6f1ce 100644 --- a/sys/arch/i386/pci/ichpcib.c +++ b/sys/arch/i386/pci/ichpcib.c @@ -187,7 +187,7 @@ ichss_present(struct pci_attach_args *pa) /* * This form of SpeedStep works only with certain Intel processors. * However, other processors can be coupled with these ICH southbridges - * causing false positives. This heuristic comes partly from the + * causing false positives. This heuristic comes partly from the * Linux speedstep-ich driver. */ if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82801DBM_LPC || diff --git a/sys/arch/i386/pci/opti82c558.c b/sys/arch/i386/pci/opti82c558.c index dc961ac56..0a4fd63ed 100644 --- a/sys/arch/i386/pci/opti82c558.c +++ b/sys/arch/i386/pci/opti82c558.c @@ -42,18 +42,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/opti82c558reg.h b/sys/arch/i386/pci/opti82c558reg.h index 2cc016b84..253d0ebda 100644 --- a/sys/arch/i386/pci/opti82c558reg.h +++ b/sys/arch/i386/pci/opti82c558reg.h @@ -12,18 +12,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/opti82c700.c b/sys/arch/i386/pci/opti82c700.c index 5512ca95d..2adbc2155 100644 --- a/sys/arch/i386/pci/opti82c700.c +++ b/sys/arch/i386/pci/opti82c700.c @@ -42,18 +42,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/opti82c700reg.h b/sys/arch/i386/pci/opti82c700reg.h index 4dd743cb5..43996b541 100644 --- a/sys/arch/i386/pci/opti82c700reg.h +++ b/sys/arch/i386/pci/opti82c700reg.h @@ -12,18 +12,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/pci_addr_fixup.c b/sys/arch/i386/pci/pci_addr_fixup.c index 27e3ca929..aa2afdb42 100644 --- a/sys/arch/i386/pci/pci_addr_fixup.c +++ b/sys/arch/i386/pci/pci_addr_fixup.c @@ -78,12 +78,12 @@ void pci_addr_fixup(struct pcibios_softc *sc, pci_chipset_tag_t pc, int maxbus) { extern paddr_t avail_end; - const char *verbose_header = + const char *verbose_header = "[%s]-----------------------\n" " device vendor product\n" " register space address size\n" "--------------------------------------------\n"; - const char *verbose_footer = + const char *verbose_footer = "--------------------------[%3d devices bogus]\n"; const struct { @@ -106,7 +106,7 @@ pci_addr_fixup(struct pcibios_softc *sc, pci_chipset_tag_t pc, int maxbus) PCIADDR_PORT_START, PCIADDR_PORT_END, M_DEVBUF, 0, 0, EX_NOWAIT); KASSERT(sc->extent_port); - /* + /* * 1. check & reserve system BIOS setting. */ PCIBIOS_PRINTV((verbose_header, "System BIOS Setting")); @@ -114,19 +114,19 @@ pci_addr_fixup(struct pcibios_softc *sc, pci_chipset_tag_t pc, int maxbus) pci_device_foreach(sc, pc, maxbus, pciaddr_resource_reserve_disabled); PCIBIOS_PRINTV((verbose_footer, sc->nbogus)); - /* + /* * 2. reserve non-PCI area. */ for (srp = system_reserve; srp->size; srp++) { error = extent_alloc_region(sc->extent_mem, srp->start, - srp->size, EX_NOWAIT| EX_MALLOCOK); + srp->size, EX_NOWAIT| EX_MALLOCOK); if (error != 0) printf("WARNING: can't reserve area for %s.\n", srp->name); } - /* - * 3. determine allocation space + /* + * 3. determine allocation space */ start = round_page(avail_end + 1); if (start < PCIADDR_ISAMEM_RESERVE) @@ -136,8 +136,8 @@ pci_addr_fixup(struct pcibios_softc *sc, pci_chipset_tag_t pc, int maxbus) PCIBIOS_PRINTV((" Physical memory end: 0x%08lx\n PCI memory mapped I/O " "space start: 0x%08lx\n", avail_end, sc->mem_alloc_start)); - /* - * 4. do fixup + /* + * 4. do fixup */ PCIBIOS_PRINTV((verbose_header, "PCIBIOS fixup stage")); sc->nbogus = 0; @@ -191,7 +191,7 @@ pciaddr_resource_manage(struct pcibios_softc *sc, pci_chipset_tag_t pc, PCI_HDRTYPE_TYPE(val)); sc->nbogus++; return; - case 0: + case 0: reg_start = PCI_MAPREG_START; reg_end = PCI_MAPREG_END; break; @@ -205,7 +205,7 @@ pciaddr_resource_manage(struct pcibios_softc *sc, pci_chipset_tag_t pc, break; } error = 0; - + for (mapreg = reg_start; mapreg < reg_end; mapreg += width) { /* inquire PCI device bus space requirement */ val = pci_conf_read(pc, tag, mapreg); @@ -213,20 +213,20 @@ pciaddr_resource_manage(struct pcibios_softc *sc, pci_chipset_tag_t pc, mask = pci_conf_read(pc, tag, mapreg); pci_conf_write(pc, tag, mapreg, val); - + type = PCI_MAPREG_TYPE(val); width = 4; if (type == PCI_MAPREG_TYPE_MEM) { - if (PCI_MAPREG_MEM_TYPE(val) == + if (PCI_MAPREG_MEM_TYPE(val) == PCI_MAPREG_MEM_TYPE_64BIT) { /* XXX We could examine the upper 32 bits - * XXX of the BAR here, but we are totally - * XXX unprepared to handle a non-zero value, - * XXX either here or anywhere else in - * XXX i386-land. + * XXX of the BAR here, but we are totally + * XXX unprepared to handle a non-zero value, + * XXX either here or anywhere else in + * XXX i386-land. * XXX So just arrange to not look at the * XXX upper 32 bits, lest we misinterpret - * XXX it as a 32-bit BAR set to zero. + * XXX it as a 32-bit BAR set to zero. */ width = 8; } @@ -239,15 +239,15 @@ pciaddr_resource_manage(struct pcibios_softc *sc, pci_chipset_tag_t pc, size = PCI_MAPREG_IO_SIZE(mask); ex = sc->extent_port; } - + if (!size) /* unused register */ continue; /* reservation/allocation phase */ error += (*func) (sc, pc, tag, mapreg, ex, type, &addr, size); - PCIBIOS_PRINTV(("\t%02xh %s 0x%08x 0x%08x\n", - mapreg, type ? "port" : "mem ", + PCIBIOS_PRINTV(("\t%02xh %s 0x%08x 0x%08x\n", + mapreg, type ? "port" : "mem ", (unsigned int)addr, (unsigned int)size)); } @@ -264,14 +264,14 @@ pciaddr_do_resource_allocate(struct pcibios_softc *sc, pci_chipset_tag_t pc, { bus_addr_t start; int error; - + if (*addr) /* no need to allocate */ return (0); /* XXX Don't allocate if device is AGP device to avoid conflict. */ - if (pciaddr_device_is_agp(pc, tag)) + if (pciaddr_device_is_agp(pc, tag)) return (0); - + start = (type == PCI_MAPREG_TYPE_MEM ? sc->mem_alloc_start : sc->port_alloc_start); if (start < ex->ex_start || start + size - 1 >= ex->ex_end) { @@ -375,12 +375,12 @@ pciaddr_ioaddr(u_int32_t val) void pciaddr_print_devid(pci_chipset_tag_t pc, pcitag_t tag) { - int bus, device, function; + int bus, device, function; pcireg_t id; - + id = pci_conf_read(pc, tag, PCI_ID_REG); pci_decompose_tag(pc, tag, &bus, &device, &function); - printf("%03d:%02d:%d %04x:%04x\n", bus, device, function, + printf("%03d:%02d:%d %04x:%04x\n", bus, device, function, PCI_VENDOR(id), PCI_PRODUCT(id)); } @@ -400,7 +400,7 @@ pciaddr_device_is_agp(pci_chipset_tag_t pc, pcitag_t tag) off != 0; off = PCI_CAPLIST_NEXT(rval) ) { rval = pci_conf_read(pc, tag, off); - if (PCI_CAPLIST_CAP(rval) == PCI_CAP_AGP) + if (PCI_CAPLIST_CAP(rval) == PCI_CAP_AGP) return (1); } } diff --git a/sys/arch/i386/pci/pci_bus_fixup.c b/sys/arch/i386/pci/pci_bus_fixup.c index 3e21d81e9..fe70295d4 100644 --- a/sys/arch/i386/pci/pci_bus_fixup.c +++ b/sys/arch/i386/pci/pci_bus_fixup.c @@ -12,18 +12,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* @@ -256,11 +256,11 @@ pci_bus_fixup(pci_chipset_tag_t pc, int bus) void pcibus_print_devid(pci_chipset_tag_t pc, pcitag_t tag) { - int bus, device, function; + int bus, device, function; pcireg_t id; id = pci_conf_read(pc, tag, PCI_ID_REG); pci_decompose_tag(pc, tag, &bus, &device, &function); - printf("%03d:%02d:%d %04x:%04x\n", bus, device, function, + printf("%03d:%02d:%d %04x:%04x\n", bus, device, function, PCI_VENDOR(id), PCI_PRODUCT(id)); } diff --git a/sys/arch/i386/pci/pci_machdep.c b/sys/arch/i386/pci/pci_machdep.c index 9887a48f8..0e507af47 100644 --- a/sys/arch/i386/pci/pci_machdep.c +++ b/sys/arch/i386/pci/pci_machdep.c @@ -175,7 +175,7 @@ struct { */ struct bus_dma_tag pci_bus_dma_tag = { NULL, /* _cookie */ - _bus_dmamap_create, + _bus_dmamap_create, _bus_dmamap_destroy, _bus_dmamap_load, _bus_dmamap_load_mbuf, @@ -595,7 +595,7 @@ pci_mode_detect(void) return (pci_mode); not1: outl(PCI_MODE1_ADDRESS_REG, sav); - + /* * This mode 2 check is quite weak (and known to give false * positives on some Compaq machines). @@ -865,7 +865,7 @@ pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, #if NIOAPIC > 0 if (l != -1 && ih.line & APIC_INT_VIA_APIC) - return (apic_intr_establish(ih.line, IST_LEVEL, level, func, + return (apic_intr_establish(ih.line, IST_LEVEL, level, func, arg, what)); #endif if (l == 0 || l >= ICU_LEN || l == 2) @@ -888,7 +888,7 @@ pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie) pcitag_t tag = { .mode1 = ih->ih_pin }; pcireg_t reg; int off; - + if (pci_get_capability(pc, tag, PCI_CAP_MSI, &off, ®)) pci_conf_write(pc, tag, off, reg &= ~PCI_MSI_MC_MSIE); diff --git a/sys/arch/i386/pci/pcibios.c b/sys/arch/i386/pci/pcibios.c index 36f19fbfd..699e553cb 100644 --- a/sys/arch/i386/pci/pcibios.c +++ b/sys/arch/i386/pci/pcibios.c @@ -66,18 +66,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* @@ -253,7 +253,7 @@ pcibios_pir_init(struct pcibios_softc *sc) if (pirh->signature != BIOS32_MAKESIG('$', 'P', 'I', 'R') && pirh->signature != BIOS32_MAKESIG('_', 'P', 'I', 'R')) continue; - + if (pirh->tablesize < sizeof(*pirh)) continue; diff --git a/sys/arch/i386/pci/pciide_gcsc_reg.h b/sys/arch/i386/pci/pciide_gcsc_reg.h index 260989769..24732bea6 100644 --- a/sys/arch/i386/pci/pciide_gcsc_reg.h +++ b/sys/arch/i386/pci/pciide_gcsc_reg.h @@ -27,7 +27,7 @@ */ -/* +/* * 6.4 - ATA-5 Controller Register Definitions. */ #define GCSC_MSR_ATAC_BASE 0x51300000 diff --git a/sys/arch/i386/pci/pciide_machdep.c b/sys/arch/i386/pci/pciide_machdep.c index ce4ab653c..05c4bd99f 100644 --- a/sys/arch/i386/pci/pciide_machdep.c +++ b/sys/arch/i386/pci/pciide_machdep.c @@ -146,7 +146,7 @@ gcsc_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa) pciide_unmap_compat_intr(pa, cp, 0, interface); return; } - + gcsc_setup_channel(&cp->wdc_channel); } diff --git a/sys/arch/i386/pci/piix.c b/sys/arch/i386/pci/piix.c index d1692e189..b7edde9ba 100644 --- a/sys/arch/i386/pci/piix.c +++ b/sys/arch/i386/pci/piix.c @@ -42,18 +42,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/piixreg.h b/sys/arch/i386/pci/piixreg.h index 8e60d3d8f..7c6f8bc43 100644 --- a/sys/arch/i386/pci/piixreg.h +++ b/sys/arch/i386/pci/piixreg.h @@ -12,18 +12,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/piixvar.h b/sys/arch/i386/pci/piixvar.h index fdfbf0b7a..ade869cdf 100644 --- a/sys/arch/i386/pci/piixvar.h +++ b/sys/arch/i386/pci/piixvar.h @@ -42,18 +42,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/rccosb4reg.h b/sys/arch/i386/pci/rccosb4reg.h index 69a9407e1..1ff3fef9f 100644 --- a/sys/arch/i386/pci/rccosb4reg.h +++ b/sys/arch/i386/pci/rccosb4reg.h @@ -12,18 +12,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/sis85c503.c b/sys/arch/i386/pci/sis85c503.c index 604186daf..ec3bc76d8 100644 --- a/sys/arch/i386/pci/sis85c503.c +++ b/sys/arch/i386/pci/sis85c503.c @@ -42,18 +42,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/sis85c503reg.h b/sys/arch/i386/pci/sis85c503reg.h index 71c984e17..b6fc65ba7 100644 --- a/sys/arch/i386/pci/sis85c503reg.h +++ b/sys/arch/i386/pci/sis85c503reg.h @@ -12,18 +12,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/pci/via82c586.c b/sys/arch/i386/pci/via82c586.c index 24891bba6..296bc17f4 100644 --- a/sys/arch/i386/pci/via82c586.c +++ b/sys/arch/i386/pci/via82c586.c @@ -42,18 +42,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* @@ -117,7 +117,7 @@ via82c586_init(pci_chipset_tag_t pc, bus_space_tag_t iot, pcitag_t tag, if (piix_init(pc, iot, tag, ptagp, phandp) == 0) { *ptagp = &via82c586_pci_icu; - + /* * Enable EISA ELCR. */ diff --git a/sys/arch/i386/pci/via82c586reg.h b/sys/arch/i386/pci/via82c586reg.h index 5a25b7d35..98691b44b 100644 --- a/sys/arch/i386/pci/via82c586reg.h +++ b/sys/arch/i386/pci/via82c586reg.h @@ -12,18 +12,18 @@ * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/sys/arch/i386/stand/biosboot/biosboot.S b/sys/arch/i386/stand/biosboot/biosboot.S index b0b8a6ff0..d6f3cfc03 100644 --- a/sys/arch/i386/stand/biosboot/biosboot.S +++ b/sys/arch/i386/stand/biosboot/biosboot.S @@ -15,8 +15,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -164,7 +164,7 @@ _start: . = _start + 3 - .asciz "OpenBSD" + .asciz "SecBSD" /* BPB */ . = _start + 0x0b diff --git a/sys/arch/i386/stand/boot/Makefile b/sys/arch/i386/stand/boot/Makefile index 8672157dd..b57d1fbb8 100644 --- a/sys/arch/i386/stand/boot/Makefile +++ b/sys/arch/i386/stand/boot/Makefile @@ -54,7 +54,7 @@ SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ .endif .PATH: ${S}/lib/libkern -SRCS+= ashldi3.c ashrdi3.c divdi3.c lshrdi3.c moddi3.c qdivrem.c +SRCS+= ashldi3.c ashrdi3.c divdi3.c lshrdi3.c moddi3.c qdivrem.c SRCS+= strlcpy.c .PATH: ${S}/lib/libz diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c index f76ffad2c..28524e55a 100644 --- a/sys/arch/i386/stand/boot/conf.c +++ b/sys/arch/i386/stand/boot/conf.c @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/boot/srt0.S b/sys/arch/i386/stand/boot/srt0.S index f747207a2..2f82e5082 100644 --- a/sys/arch/i386/stand/boot/srt0.S +++ b/sys/arch/i386/stand/boot/srt0.S @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/cdboot/conf.c b/sys/arch/i386/stand/cdboot/conf.c index e18d8ba32..aa2e9a360 100644 --- a/sys/arch/i386/stand/cdboot/conf.c +++ b/sys/arch/i386/stand/cdboot/conf.c @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/cdboot/srt0.S b/sys/arch/i386/stand/cdboot/srt0.S index 1c6efca6d..48b54b6a0 100644 --- a/sys/arch/i386/stand/cdboot/srt0.S +++ b/sys/arch/i386/stand/cdboot/srt0.S @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -199,7 +199,7 @@ ENTRY(debugchar) xorl %eax, %eax movb 12(%esp), %al - + andl $0xfffffffe, %ebx movb %al, (%ebx) popl %ebx diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c index daea9d3bf..752987800 100644 --- a/sys/arch/i386/stand/libsa/biosdev.c +++ b/sys/arch/i386/stand/libsa/biosdev.c @@ -578,7 +578,7 @@ biosopen(struct open_file *f, ...) return 0; } #endif - + for (maj = 0; maj < nbdevs && strncmp(dev, bdevs[maj], devlen); maj++); if (maj >= nbdevs) { diff --git a/sys/arch/i386/stand/libsa/biosdev.h b/sys/arch/i386/stand/libsa/biosdev.h index 588f03150..4d69aebf3 100644 --- a/sys/arch/i386/stand/libsa/biosdev.h +++ b/sys/arch/i386/stand/libsa/biosdev.h @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/debug.h b/sys/arch/i386/stand/libsa/debug.h index 08807db56..942f92b21 100644 --- a/sys/arch/i386/stand/libsa/debug.h +++ b/sys/arch/i386/stand/libsa/debug.h @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/debug_i386.S b/sys/arch/i386/stand/libsa/debug_i386.S index 6b861e773..f07154f26 100644 --- a/sys/arch/i386/stand/libsa/debug_i386.S +++ b/sys/arch/i386/stand/libsa/debug_i386.S @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/debug_md.h b/sys/arch/i386/stand/libsa/debug_md.h index 9508aa0e8..6819371a1 100644 --- a/sys/arch/i386/stand/libsa/debug_md.h +++ b/sys/arch/i386/stand/libsa/debug_md.h @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/disk.h b/sys/arch/i386/stand/libsa/disk.h index 5d46a506d..28d46ad81 100644 --- a/sys/arch/i386/stand/libsa/disk.h +++ b/sys/arch/i386/stand/libsa/disk.h @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/gidt.S b/sys/arch/i386/stand/libsa/gidt.S index 66809f4d0..06fc64ba3 100644 --- a/sys/arch/i386/stand/libsa/gidt.S +++ b/sys/arch/i386/stand/libsa/gidt.S @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -195,7 +195,7 @@ pmm_init: idte(mc) idte(xx); idte(xx); idte(xx); idte(xx); idte(xx); idte(xx) idte(xx); idte(xx); idte(xx); idte(xx); idte(xx); idte(xx) - idte(xx) + idte(xx) /* BIOS entry points (32-63) */ idtb(0); idtb(1); idtb(2); idtb(3); idtb(4); idtb(5) idtb(6); idtb(7); idtb(8); idtb(9); idtb(10); idtb(11) diff --git a/sys/arch/i386/stand/libsa/gidt.h b/sys/arch/i386/stand/libsa/gidt.h index 457709674..7c0966bd3 100644 --- a/sys/arch/i386/stand/libsa/gidt.h +++ b/sys/arch/i386/stand/libsa/gidt.h @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/mdrandom.c b/sys/arch/i386/stand/libsa/mdrandom.c index 507a0f6c8..15c81b08b 100644 --- a/sys/arch/i386/stand/libsa/mdrandom.c +++ b/sys/arch/i386/stand/libsa/mdrandom.c @@ -1,7 +1,7 @@ /* $OpenBSD: mdrandom.c,v 1.3 2020/06/19 15:00:45 naddy Exp $ */ /* - * Copyright (c) 2020 Theo de Raadt + * Copyright (c) 2020 Theo de Raadt * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/sys/arch/i386/stand/libsa/pciprobe.c b/sys/arch/i386/stand/libsa/pciprobe.c index 9854aa4cb..6ce15036d 100644 --- a/sys/arch/i386/stand/libsa/pciprobe.c +++ b/sys/arch/i386/stand/libsa/pciprobe.c @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/pslid.S b/sys/arch/i386/stand/libsa/pslid.S index 40f9b0e9f..6bcf22328 100644 --- a/sys/arch/i386/stand/libsa/pslid.S +++ b/sys/arch/i386/stand/libsa/pslid.S @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/libsa/pxe.h b/sys/arch/i386/stand/libsa/pxe.h index 7080d627f..69ea10301 100644 --- a/sys/arch/i386/stand/libsa/pxe.h +++ b/sys/arch/i386/stand/libsa/pxe.h @@ -87,7 +87,7 @@ typedef struct { uint16_t UNDIDataSize; /* UNDI Data segment size (bytes) */ SEGSEL_t UNDICodeSeg; /* UNDI Code segment address */ uint16_t UNDICodeSize; /* UNDI Code segment size (bytes) */ - SEGOFF16_t PXEPtr; /* SEG:OFF to !PXE struct, + SEGOFF16_t PXEPtr; /* SEG:OFF to !PXE struct, only present when Version > 2.1 */ } __packed pxenv_t; @@ -151,7 +151,7 @@ typedef struct { MAC_ADDR McastAddr[MAXNUM_MCADDR]; } __packed t_PXENV_UNDI_MCAST_ADDRESS; -#define PXENV_UNDI_RESET_ADAPTER 0x0004 +#define PXENV_UNDI_RESET_ADAPTER 0x0004 typedef struct { PXENV_STATUS_t Status; t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf; @@ -463,7 +463,7 @@ typedef struct { } __packed t_PXENV_GET_CACHED_INFO; -/* structure filled in by PXENV_GET_CACHED_INFO +/* structure filled in by PXENV_GET_CACHED_INFO * (how we determine which IP we downloaded the initial bootstrap from) * words can't describe... */ diff --git a/sys/arch/i386/stand/libsa/time.c b/sys/arch/i386/stand/libsa/time.c index d1612a3cc..668d51f69 100644 --- a/sys/arch/i386/stand/libsa/time.c +++ b/sys/arch/i386/stand/libsa/time.c @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/mbr/mbr.S b/sys/arch/i386/stand/mbr/mbr.S index cc172b692..9fd236841 100644 --- a/sys/arch/i386/stand/mbr/mbr.S +++ b/sys/arch/i386/stand/mbr/mbr.S @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/pxeboot/conf.c b/sys/arch/i386/stand/pxeboot/conf.c index f02264175..90c7f797e 100644 --- a/sys/arch/i386/stand/pxeboot/conf.c +++ b/sys/arch/i386/stand/pxeboot/conf.c @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL diff --git a/sys/arch/i386/stand/pxeboot/srt0.S b/sys/arch/i386/stand/pxeboot/srt0.S index 7d5739d17..6781d984d 100644 --- a/sys/arch/i386/stand/pxeboot/srt0.S +++ b/sys/arch/i386/stand/pxeboot/srt0.S @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -194,7 +194,7 @@ ENTRY(debugchar) xorl %eax, %eax movb 12(%esp), %al - + andl $0xfffffffe, %ebx movb %al, (%ebx) popl %ebx diff --git a/sys/dev/dt/dt_dev.c b/sys/dev/dt/dt_dev.c index 4236a6fc9..a103c4067 100644 --- a/sys/dev/dt/dt_dev.c +++ b/sys/dev/dt/dt_dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_dev.c,v 1.27 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: dt_dev.c,v 1.28 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -224,7 +224,6 @@ dtclose(dev_t dev, int flags, int mode, struct proc *p) int dtread(dev_t dev, struct uio *uio, int flags) { - struct sleep_state sls; struct dt_softc *sc; struct dt_evt *estq; struct dt_pcb *dp; @@ -240,8 +239,8 @@ dtread(dev_t dev, struct uio *uio, int flags) return (EMSGSIZE); while (!sc->ds_evtcnt) { - sleep_setup(&sls, sc, PWAIT | PCATCH, "dtread"); - error = sleep_finish(&sls, PWAIT | PCATCH, 0, !sc->ds_evtcnt); + sleep_setup(sc, PWAIT | PCATCH, "dtread"); + error = sleep_finish(0, !sc->ds_evtcnt); if (error == EINTR || error == ERESTART) break; } diff --git a/sys/dev/fdt/rkgpio.c b/sys/dev/fdt/rkgpio.c index ebfad5484..a7e9f776c 100644 --- a/sys/dev/fdt/rkgpio.c +++ b/sys/dev/fdt/rkgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rkgpio.c,v 1.10 2023/03/05 14:45:07 patrick Exp $ */ +/* $OpenBSD: rkgpio.c,v 1.11 2023/07/10 13:48:02 patrick Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * Copyright (c) 2019 Patrick Wildt @@ -56,6 +56,9 @@ #define GPIO_INT_TYPE_H 0x0024 #define GPIO_INT_POLARITY_L 0x0028 #define GPIO_INT_POLARITY_H 0x002c +#define GPIO_INT_STATUS_V2 0x0050 +#define GPIO_PORT_EOI_L 0x0060 +#define GPIO_PORT_EOI_H 0x0064 #define GPIO_EXT_PORT 0x0070 #define GPIO_VER_ID 0x0078 #define GPIO_VER_ID_1_0 0x00000000 @@ -276,7 +279,10 @@ rkgpio_intr(void *cookie) uint32_t status, pending; int pin, s; - status = HREAD4(sc, GPIO_INT_STATUS); + if (sc->sc_version == 2) + status = HREAD4(sc, GPIO_INT_STATUS_V2); + else + status = HREAD4(sc, GPIO_INT_STATUS); pending = status; while (pending) { @@ -292,7 +298,13 @@ rkgpio_intr(void *cookie) pending &= ~(1 << pin); } - HWRITE4(sc, GPIO_PORTS_EOI, status); + if (sc->sc_version == 2) { + HWRITE4(sc, GPIO_PORT_EOI_L, + (status & 0xffff) << 16 | (status & 0xffff)); + HWRITE4(sc, GPIO_PORT_EOI_H, + status >> 16 | (status & 0xffff0000)); + } else + HWRITE4(sc, GPIO_PORTS_EOI, status); return 1; } diff --git a/sys/dev/fdt/rkpciephy.c b/sys/dev/fdt/rkpciephy.c index da5b50e84..b0fa42ad2 100644 --- a/sys/dev/fdt/rkpciephy.c +++ b/sys/dev/fdt/rkpciephy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rkpciephy.c,v 1.2 2023/07/08 09:12:28 patrick Exp $ */ +/* $OpenBSD: rkpciephy.c,v 1.3 2023/07/09 19:11:30 patrick Exp $ */ /* * Copyright (c) 2023 Mark Kettenis * @@ -202,18 +202,16 @@ rk3588_pciephy_enable(void *cookie, uint32_t *cells) } regmap_write_4(phy, RK3588_PCIE3PHY_GRF_CMN_CON(0), reg); - grf = OF_getpropint(node, "rockchip,phy-grf", 0); + grf = OF_getpropint(node, "rockchip,pipe-grf", 0); pipe = regmap_byphandle(grf); if (pipe != NULL) { reg = RK3588_PHP_GRF_PCIE0L0_MASK | RK3588_PHP_GRF_PCIE0L1_MASK; - /* If lane 1 is configured, move it from Combo to PCIE3 PHY */ - if (num_lanes >= 2 && data_lanes[1] != 0) { + /* If lane 1 goes to PCIe3_1L0, move from Combo to PCIE3 PHY */ + if (num_lanes >= 2 && data_lanes[1] == 2) reg |= RK3588_PHP_GRF_PCIE0L0_PCIE3; - } - /* If lane 3 is configured, move it from Combo to PCIE3 PHY */ - if (num_lanes >= 4 && data_lanes[3] != 0) { + /* If lane 3 goes to PCIe3_1L1, move from Combo to PCIE3 PHY */ + if (num_lanes >= 4 && data_lanes[3] == 4) reg |= RK3588_PHP_GRF_PCIE0L1_PCIE3; - } regmap_write_4(pipe, RK3588_PHP_GRF_PCIESEL_CON, reg); } diff --git a/sys/dev/fdt/tascodec.c b/sys/dev/fdt/tascodec.c index 572847c22..1c63afd39 100644 --- a/sys/dev/fdt/tascodec.c +++ b/sys/dev/fdt/tascodec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tascodec.c,v 1.6 2023/02/04 20:04:20 kettenis Exp $ */ +/* $OpenBSD: tascodec.c,v 1.7 2023/07/15 13:35:17 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -35,6 +35,7 @@ #define PWR_CTL 0x02 #define PWR_CTL_ISNS_PD (1 << 3) #define PWR_CTL_VSNS_PD (1 << 2) +#define PWR_CTL_MODE_MASK (3 << 0) #define PWR_CTL_MODE_ACTIVE (0 << 0) #define PWR_CTL_MODE_MUTE (1 << 0) #define PWR_CTL_MODE_SHUTDOWN (2 << 0) @@ -66,6 +67,7 @@ struct tascodec_softc { struct dai_device sc_dai; uint8_t sc_dvc; + uint8_t sc_mute; }; int tascodec_match(struct device *, void *, void *); @@ -138,6 +140,7 @@ tascodec_attach(struct device *parent, struct device *self, void *aux) /* Set volume to a reasonable level. */ sc->sc_dvc = PB_CFG2_DVC_PCM_30DB; + sc->sc_mute = PWR_CTL_MODE_ACTIVE; tascodec_write(sc, PB_CFG2, sc->sc_dvc); /* Default to stereo downmix mode for now. */ @@ -244,6 +247,7 @@ tascodec_set_tdm_slot(void *cookie, int slot) */ enum { TASCODEC_MASTER_VOL, + TASCODEC_MASTER_MUTE, TASCODEC_OUTPUT_CLASS }; @@ -252,6 +256,7 @@ tascodec_set_port(void *priv, mixer_ctrl_t *mc) { struct tascodec_softc *sc = priv; u_char level; + uint8_t mode; switch (mc->dev) { case TASCODEC_MASTER_VOL: @@ -259,6 +264,19 @@ tascodec_set_port(void *priv, mixer_ctrl_t *mc) sc->sc_dvc = (PB_CFG2_DVC_PCM_MIN * (255 - level)) / 255; tascodec_write(sc, PB_CFG2, sc->sc_dvc); return 0; + + case TASCODEC_MASTER_MUTE: + sc->sc_mute = mc->un.ord ? + PWR_CTL_MODE_MUTE : PWR_CTL_MODE_ACTIVE; + mode = tascodec_read(sc, PWR_CTL); + if ((mode & PWR_CTL_MODE_MASK) == PWR_CTL_MODE_ACTIVE || + (mode & PWR_CTL_MODE_MASK) == PWR_CTL_MODE_MUTE) { + mode &= ~PWR_CTL_MODE_MASK; + mode |= sc->sc_mute; + tascodec_write(sc, PWR_CTL, mode); + } + return 0; + } return EINVAL; @@ -276,6 +294,10 @@ tascodec_get_port(void *priv, mixer_ctrl_t *mc) level = 255 - ((255 * sc->sc_dvc) / PB_CFG2_DVC_PCM_MIN); mc->un.value.level[AUDIO_MIXER_LEVEL_MONO] = level; return 0; + + case TASCODEC_MASTER_MUTE: + mc->un.ord = (sc->sc_mute == PWR_CTL_MODE_MUTE); + return 0; } return EINVAL; @@ -287,7 +309,8 @@ tascodec_query_devinfo(void *priv, mixer_devinfo_t *di) switch (di->index) { case TASCODEC_MASTER_VOL: di->mixer_class = TASCODEC_OUTPUT_CLASS; - di->next = di->prev = AUDIO_MIXER_LAST; + di->prev = AUDIO_MIXER_LAST; + di->next = TASCODEC_MASTER_MUTE; strlcpy(di->label.name, AudioNmaster, sizeof(di->label.name)); di->type = AUDIO_MIXER_VALUE; di->un.v.num_channels = 1; @@ -295,6 +318,21 @@ tascodec_query_devinfo(void *priv, mixer_devinfo_t *di) sizeof(di->un.v.units.name)); return 0; + case TASCODEC_MASTER_MUTE: + di->mixer_class = TASCODEC_OUTPUT_CLASS; + di->prev = TASCODEC_MASTER_VOL; + di->next = AUDIO_MIXER_LAST; + strlcpy(di->label.name, AudioNmute, sizeof(di->label.name)); + di->type = AUDIO_MIXER_ENUM; + di->un.e.num_mem = 2; + di->un.e.member[0].ord = 0; + strlcpy(di->un.e.member[0].label.name, AudioNoff, + MAX_AUDIO_DEV_LEN); + di->un.e.member[1].ord = 1; + strlcpy(di->un.e.member[1].label.name, AudioNon, + MAX_AUDIO_DEV_LEN); + return 0; + case TASCODEC_OUTPUT_CLASS: di->mixer_class = TASCODEC_OUTPUT_CLASS; di->next = di->prev = AUDIO_MIXER_LAST; @@ -313,7 +351,7 @@ tascodec_trigger_output(void *cookie, void *start, void *end, int blksize, struct tascodec_softc *sc = cookie; tascodec_write(sc, PWR_CTL, - PWR_CTL_ISNS_PD | PWR_CTL_VSNS_PD | PWR_CTL_MODE_ACTIVE); + PWR_CTL_ISNS_PD | PWR_CTL_VSNS_PD | sc->sc_mute); return 0; } diff --git a/sys/dev/fdt/tipd.c b/sys/dev/fdt/tipd.c index 711be1756..70bb7ca15 100644 --- a/sys/dev/fdt/tipd.c +++ b/sys/dev/fdt/tipd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tipd.c,v 1.1 2022/12/12 19:18:25 kettenis Exp $ */ +/* $OpenBSD: tipd.c,v 1.2 2023/07/17 17:50:22 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -29,6 +29,8 @@ #include +#define TPS_CMD1 0x08 +#define TPS_DATA1 0x09 #define TPS_INT_EVENT_1 0x14 #define TPS_INT_EVENT_2 0x15 #define TPS_INT_MASK_1 0x16 @@ -37,6 +39,11 @@ #define TPS_INT_CLEAR_2 0x19 #define TPS_STATUS 0x1a #define TPS_STATUS_PLUG_PRESENT (1 << 0) +#define TPS_SYSTEM_POWER_STATE 0x20 +#define TPS_SYSTEM_POWER_STATE_S0 0 +#define TPS_SYSTEM_POWER_STATE_S5 5 + +#define TPS_CMD(s) ((s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0]) /* * Interrupt bits on the CD321x controllers used by Apple differ from @@ -56,9 +63,11 @@ struct tipd_softc { int tipd_match(struct device *, void *, void *); void tipd_attach(struct device *, struct device *, void *); +int tipd_activate(struct device *, int); const struct cfattach tipd_ca = { - sizeof(struct tipd_softc), tipd_match, tipd_attach + sizeof(struct tipd_softc), tipd_match, tipd_attach, NULL, + tipd_activate }; struct cfdriver tipd_cd = { @@ -69,7 +78,10 @@ int tipd_intr(void *); int tipd_read_4(struct tipd_softc *, uint8_t, uint32_t *); int tipd_read_8(struct tipd_softc *, uint8_t, uint64_t *); +int tipd_write_4(struct tipd_softc *, uint8_t, uint32_t); int tipd_write_8(struct tipd_softc *, uint8_t, uint64_t); +int tipd_exec(struct tipd_softc *, const char *, + const void *, size_t, void *, size_t); int tipd_match(struct device *parent, void *match, void *aux) @@ -107,6 +119,31 @@ tipd_attach(struct device *parent, struct device *self, void *aux) } } +int +tipd_activate(struct device *self, int act) +{ + struct tipd_softc *sc = (struct tipd_softc *)self; + uint8_t state; + int error; + + switch (act) { + case DVACT_SUSPEND: + state = TPS_SYSTEM_POWER_STATE_S5; + error = tipd_exec(sc, "SSPS", &state, sizeof(state), NULL, 0); + if (error) + printf("%s: powerdown failed\n", sc->sc_dev.dv_xname); + break; + case DVACT_RESUME: + state = TPS_SYSTEM_POWER_STATE_S0; + error = tipd_exec(sc, "SSPS", &state, sizeof(state), NULL, 0); + if (error) + printf("%s: powerup failed\n", sc->sc_dev.dv_xname); + break; + } + + return 0; +} + void tipd_connect(struct tipd_softc *sc) { @@ -206,6 +243,23 @@ tipd_read_8(struct tipd_softc *sc, uint8_t reg, uint64_t *val) return error; } +int +tipd_write_4(struct tipd_softc *sc, uint8_t reg, uint32_t val) +{ + uint8_t buf[5]; + int error; + + buf[0] = 4; + htolem32(&buf[1], val); + + iic_acquire_bus(sc->sc_tag, 0); + error = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, + sc->sc_addr, ®, sizeof(reg), buf, sizeof(buf), 0); + iic_release_bus(sc->sc_tag, 0); + + return error; +} + int tipd_write_8(struct tipd_softc *sc, uint8_t reg, uint64_t val) { @@ -222,3 +276,66 @@ tipd_write_8(struct tipd_softc *sc, uint8_t reg, uint64_t val) return error; } + +int +tipd_exec(struct tipd_softc *sc, const char *cmd, const void *wbuf, + size_t wlen, void *rbuf, size_t rlen) +{ + char buf[65]; + uint32_t val; + int timo, error; + uint8_t reg = TPS_DATA1; + + if (wlen >= sizeof(buf) - 1) + return EINVAL; + + error = tipd_read_4(sc, TPS_CMD1, &val); + if (error) + return error; + if (val == TPS_CMD("!CMD")) + return EBUSY; + + if (wlen > 0) { + buf[0] = wlen; + memcpy(&buf[1], wbuf, wlen); + iic_acquire_bus(sc->sc_tag, 0); + error = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, + sc->sc_addr, ®, sizeof(reg), buf, sizeof(buf), 0); + iic_release_bus(sc->sc_tag, 0); + if (error) + return error; + } + + error = tipd_write_4(sc, TPS_CMD1, TPS_CMD(cmd)); + if (error) + return error; + + for (timo = 1000; timo > 0; timo--) { + error = tipd_read_4(sc, TPS_CMD1, &val); + if (error) + return error; + if (val == TPS_CMD("!CMD")) + return EBUSY; + if (val == 0) + break; + delay(10); + } + + if (timo == 0) + return ETIMEDOUT; + + if (rlen > 0) { + memset(buf, 0, sizeof(buf)); + iic_acquire_bus(sc->sc_tag, 0); + error = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, + sc->sc_addr, ®, sizeof(reg), buf, sizeof(buf), 0); + iic_release_bus(sc->sc_tag, 0); + if (error) + return error; + if (buf[0] < rlen) + return EIO; + memcpy(rbuf, &buf[1], rlen); + } + + return 0; +} diff --git a/sys/dev/ic/aac.c b/sys/dev/ic/aac.c index 33e5fc268..8847252d5 100644 --- a/sys/dev/ic/aac.c +++ b/sys/dev/ic/aac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aac.c,v 1.94 2022/04/16 19:19:58 naddy Exp $ */ +/* $OpenBSD: aac.c,v 1.95 2023/07/13 07:31:12 jsg Exp $ */ /*- * Copyright (c) 2000 Michael Smith @@ -2074,9 +2074,7 @@ aac_rkt_set_interrupts(struct aac_softc *sc, int enable) } void -aac_eval_mapping(size, cyls, heads, secs) - u_int32_t size; - int *cyls, *heads, *secs; +aac_eval_mapping(u_int32_t size, int *cyls, int *heads, int *secs) { *cyls = size / AAC_HEADS / AAC_SECS; if (*cyls < AAC_MAXCYLS) { diff --git a/sys/dev/ic/aacvar.h b/sys/dev/ic/aacvar.h index cf6beab0f..2faaca6d0 100644 --- a/sys/dev/ic/aacvar.h +++ b/sys/dev/ic/aacvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aacvar.h,v 1.16 2022/01/09 05:42:37 jsg Exp $ */ +/* $OpenBSD: aacvar.h,v 1.17 2023/07/13 07:31:12 jsg Exp $ */ /*- * Copyright (c) 2000 Michael Smith @@ -429,31 +429,25 @@ int aac_intr(void *); /* These all require correctly aligned buffers */ static __inline__ void -aac_enc16(addr, value) - u_int8_t *addr; - u_int16_t value; +aac_enc16(u_int8_t *addr, u_int16_t value) { *(u_int16_t *)addr = htole16(value); } static __inline__ void -aac_enc32(addr, value) - u_int8_t *addr; - u_int32_t value; +aac_enc32(u_int8_t *addr, u_int32_t value) { *(u_int32_t *)addr = htole32(value); } static __inline__ u_int16_t -aac_dec16(addr) - u_int8_t *addr; +aac_dec16(u_int8_t *addr) { return letoh16(*(u_int16_t *)addr); } static __inline__ u_int32_t -aac_dec32(addr) - u_int8_t *addr; +aac_dec32(u_int8_t *addr) { return letoh32(*(u_int32_t *)addr); } diff --git a/sys/dev/pci/aac_pci.c b/sys/dev/pci/aac_pci.c index 480ad4e15..df15033af 100644 --- a/sys/dev/pci/aac_pci.c +++ b/sys/dev/pci/aac_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aac_pci.c,v 1.26 2022/03/11 18:00:45 mpi Exp $ */ +/* $OpenBSD: aac_pci.c,v 1.27 2023/07/13 07:31:12 jsg Exp $ */ /*- * Copyright (c) 2000 Michael Smith @@ -202,10 +202,7 @@ const struct cfattach aac_pci_ca = { * Determine whether this is one of our supported adapters. */ int -aac_pci_probe(parent, match, aux) - struct device *parent; - void *match; - void *aux; +aac_pci_probe(struct device *parent, void *match, void *aux) { struct pci_attach_args *pa = aux; struct aac_ident *m; @@ -224,9 +221,7 @@ aac_pci_probe(parent, match, aux) } void -aac_pci_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +aac_pci_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; pci_chipset_tag_t pc = pa->pa_pc; diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c index dea0fc8ef..8f9a1cfe2 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c @@ -129,9 +129,6 @@ static int amdgpu_cs_p1_user_fence(struct amdgpu_cs_parser *p, bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); p->uf_entry.priority = 0; p->uf_entry.tv.bo = &bo->tbo; - /* One for TTM and two for the CS job */ - p->uf_entry.tv.num_shared = 3; - drm_gem_object_put(gobj); size = amdgpu_bo_size(bo); @@ -885,15 +882,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, mutex_lock(&p->bo_list->bo_list_mutex); - /* One for TTM and one for the CS job */ + /* One for TTM and one for each CS job */ amdgpu_bo_list_for_each_entry(e, p->bo_list) - e->tv.num_shared = 2; + e->tv.num_shared = 1 + p->gang_size; + p->uf_entry.tv.num_shared = 1 + p->gang_size; amdgpu_bo_list_get_list(p->bo_list, &p->validated); INIT_LIST_HEAD(&duplicates); amdgpu_vm_get_pd_bo(&fpriv->vm, &p->validated, &p->vm_pd); + /* Two for VM updates, one for TTM and one for each CS job */ + p->vm_pd.tv.num_shared = 3 + p->gang_size; + if (p->uf_entry.tv.bo && !ttm_to_amdgpu_bo(p->uf_entry.tv.bo)->parent) list_add(&p->uf_entry.tv.head, &p->validated); diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_psp.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_psp.c index c8c5c2694..f003bef84 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_psp.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_psp.c @@ -1972,6 +1972,8 @@ static int psp_securedisplay_initialize(struct psp_context *psp) psp_securedisplay_parse_resp_status(psp, securedisplay_cmd->status); dev_err(psp->adev->dev, "SECUREDISPLAY: query securedisplay TA failed. ret 0x%x\n", securedisplay_cmd->securedisplay_out_message.query_ta.query_cmd_ret); + /* don't try again */ + psp->securedisplay_context.context.bin_desc.size_bytes = 0; } return 0; diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c index 85b3e85e0..fb5be1ce7 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c @@ -170,8 +170,7 @@ static int amdgpu_reserve_page_direct(struct amdgpu_device *adev, uint64_t addre memset(&err_rec, 0x0, sizeof(struct eeprom_table_record)); err_data.err_addr = &err_rec; - amdgpu_umc_fill_error_record(&err_data, address, - (address >> AMDGPU_GPU_PAGE_SHIFT), 0, 0); + amdgpu_umc_fill_error_record(&err_data, address, address, 0, 0); if (amdgpu_bad_page_threshold != 0) { amdgpu_ras_add_bad_pages(adev, err_data.err_addr, diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c index d3a369f6c..1d6ff4db9 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c @@ -1489,14 +1489,14 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, uint64_t eaddr; /* validate the parameters */ - if (saddr & ~LINUX_PAGE_MASK || offset & ~LINUX_PAGE_MASK || - size == 0 || size & ~LINUX_PAGE_MASK) + if (saddr & ~LINUX_PAGE_MASK || offset & ~LINUX_PAGE_MASK || size & ~LINUX_PAGE_MASK) + return -EINVAL; + if (saddr + size <= saddr || offset + size <= offset) return -EINVAL; /* make sure object fit at this offset */ eaddr = saddr + size - 1; - if (saddr >= eaddr || - (bo && offset + size > amdgpu_bo_size(bo)) || + if ((bo && offset + size > amdgpu_bo_size(bo)) || (eaddr >= adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT)) return -EINVAL; @@ -1555,14 +1555,14 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev, int r; /* validate the parameters */ - if (saddr & ~LINUX_PAGE_MASK || offset & ~LINUX_PAGE_MASK || - size == 0 || size & ~LINUX_PAGE_MASK) + if (saddr & ~LINUX_PAGE_MASK || offset & ~LINUX_PAGE_MASK || size & ~LINUX_PAGE_MASK) + return -EINVAL; + if (saddr + size <= saddr || offset + size <= offset) return -EINVAL; /* make sure object fit at this offset */ eaddr = saddr + size - 1; - if (saddr >= eaddr || - (bo && offset + size > amdgpu_bo_size(bo)) || + if ((bo && offset + size > amdgpu_bo_size(bo)) || (eaddr >= adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT)) return -EINVAL; diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c index afa246cf9..06002825a 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_mqd_manager_v9.c @@ -115,18 +115,19 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, &(mqd_mem_obj->gtt_mem), &(mqd_mem_obj->gpu_addr), (void *)&(mqd_mem_obj->cpu_ptr), true); + + if (retval) { + kfree(mqd_mem_obj); + return NULL; + } } else { retval = kfd_gtt_sa_allocate(kfd, sizeof(struct v9_mqd), &mqd_mem_obj); - } - - if (retval) { - kfree(mqd_mem_obj); - return NULL; + if (retval) + return NULL; } return mqd_mem_obj; - } static void init_mqd(struct mqd_manager *mm, void **mqd, diff --git a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 9f59a0711..188708ec0 100644 --- a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6974,13 +6974,7 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector) drm_add_modes_noedid(connector, 640, 480); } else { amdgpu_dm_connector_ddc_get_modes(connector, edid); - /* most eDP supports only timings from its edid, - * usually only detailed timings are available - * from eDP edid. timings which are not from edid - * may damage eDP - */ - if (connector->connector_type != DRM_MODE_CONNECTOR_eDP) - amdgpu_dm_connector_add_common_modes(encoder, connector); + amdgpu_dm_connector_add_common_modes(encoder, connector); amdgpu_dm_connector_add_freesync_modes(connector, edid); } amdgpu_dm_fbc_init(connector); @@ -8877,6 +8871,8 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm, /* Now check if we should set freesync video mode */ if (amdgpu_freesync_vid_mode && dm_new_crtc_state->stream && + dc_is_stream_unchanged(new_stream, dm_old_crtc_state->stream) && + dc_is_stream_scaling_unchanged(new_stream, dm_old_crtc_state->stream) && is_timing_unchanged_for_freesync(new_crtc_state, old_crtc_state)) { new_crtc_state->mode_changed = false; diff --git a/sys/dev/pci/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.c b/sys/dev/pci/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.c index eb6a935ca..11dbe3fd3 100644 --- a/sys/dev/pci/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.c +++ b/sys/dev/pci/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.c @@ -312,6 +312,9 @@ void dcn30_smu_set_display_refresh_from_mall(struct clk_mgr_internal *clk_mgr, b /* bits 8:7 for cache timer scale, bits 6:1 for cache timer delay, bit 0 = 1 for enable, = 0 for disable */ uint32_t param = (cache_timer_scale << 7) | (cache_timer_delay << 1) | (enable ? 1 : 0); + smu_print("SMU Set display refresh from mall: enable = %d, cache_timer_delay = %d, cache_timer_scale = %d\n", + enable, cache_timer_delay, cache_timer_scale); + dcn30_smu_send_msg_with_param(clk_mgr, DALSMC_MSG_SetDisplayRefreshFromMall, param, NULL); } diff --git a/sys/dev/pci/drm/amd/display/dc/core/amdgpu_dc.c b/sys/dev/pci/drm/amd/display/dc/core/amdgpu_dc.c index 087a48384..b405f2e86 100644 --- a/sys/dev/pci/drm/amd/display/dc/core/amdgpu_dc.c +++ b/sys/dev/pci/drm/amd/display/dc/core/amdgpu_dc.c @@ -2360,9 +2360,6 @@ static enum surface_update_type det_surface_update(const struct dc *dc, enum surface_update_type overall_type = UPDATE_TYPE_FAST; union surface_update_flags *update_flags = &u->surface->update_flags; - if (u->flip_addr) - update_flags->bits.addr_update = 1; - if (!is_surface_in_context(context, u->surface) || u->surface->force_full_update) { update_flags->raw = 0xFFFFFFFF; return UPDATE_TYPE_FULL; diff --git a/sys/dev/pci/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c b/sys/dev/pci/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c index b7c2844d0..f294f2f8c 100644 --- a/sys/dev/pci/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c +++ b/sys/dev/pci/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c @@ -810,7 +810,7 @@ static bool CalculatePrefetchSchedule( *swath_width_chroma_ub = dml_ceil(SwathWidthY / 2 - 1, myPipe->BlockWidth256BytesC) + myPipe->BlockWidth256BytesC; } else { *swath_width_luma_ub = dml_ceil(SwathWidthY - 1, myPipe->BlockHeight256BytesY) + myPipe->BlockHeight256BytesY; - if (myPipe->BlockWidth256BytesC > 0) + if (myPipe->BlockHeight256BytesC > 0) *swath_width_chroma_ub = dml_ceil(SwathWidthY / 2 - 1, myPipe->BlockHeight256BytesC) + myPipe->BlockHeight256BytesC; } diff --git a/sys/dev/pci/drm/amd/display/dc/dml/dcn32/display_rq_dlg_calc_32.c b/sys/dev/pci/drm/amd/display/dc/dml/dcn32/display_rq_dlg_calc_32.c index 395ae8761..9ba6cb676 100644 --- a/sys/dev/pci/drm/amd/display/dc/dml/dcn32/display_rq_dlg_calc_32.c +++ b/sys/dev/pci/drm/amd/display/dc/dml/dcn32/display_rq_dlg_calc_32.c @@ -116,7 +116,7 @@ void dml32_rq_dlg_get_rq_reg(display_rq_regs_st *rq_regs, else rq_regs->rq_regs_l.min_meta_chunk_size = dml_log2(min_meta_chunk_bytes) - 6 + 1; - if (min_meta_chunk_bytes == 0) + if (p1_min_meta_chunk_bytes == 0) rq_regs->rq_regs_c.min_meta_chunk_size = 0; else rq_regs->rq_regs_c.min_meta_chunk_size = dml_log2(p1_min_meta_chunk_bytes) - 6 + 1; diff --git a/sys/dev/pci/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/sys/dev/pci/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c index f10676395..e381c289a 100644 --- a/sys/dev/pci/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +++ b/sys/dev/pci/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c @@ -431,7 +431,13 @@ static int sienna_cichlid_append_powerplay_table(struct smu_context *smu) { struct atom_smc_dpm_info_v4_9 *smc_dpm_table; int index, ret; - I2cControllerConfig_t *table_member; + PPTable_beige_goby_t *ppt_beige_goby; + PPTable_t *ppt; + + if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 13)) + ppt_beige_goby = smu->smu_table.driver_pptable; + else + ppt = smu->smu_table.driver_pptable; index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, smc_dpm_info); @@ -440,9 +446,13 @@ static int sienna_cichlid_append_powerplay_table(struct smu_context *smu) (uint8_t **)&smc_dpm_table); if (ret) return ret; - GET_PPTABLE_MEMBER(I2cControllers, &table_member); - memcpy(table_member, smc_dpm_table->I2cControllers, - sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header)); + + if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 13)) + smu_memcpy_trailing(ppt_beige_goby, I2cControllers, BoardReserved, + smc_dpm_table, I2cControllers); + else + smu_memcpy_trailing(ppt, I2cControllers, BoardReserved, + smc_dpm_table, I2cControllers); return 0; } diff --git a/sys/dev/pci/drm/display/drm_dp_mst_topology.c b/sys/dev/pci/drm/display/drm_dp_mst_topology.c index 0a59cd719..3c233f509 100644 --- a/sys/dev/pci/drm/display/drm_dp_mst_topology.c +++ b/sys/dev/pci/drm/display/drm_dp_mst_topology.c @@ -3414,7 +3414,7 @@ int drm_dp_add_payload_part2(struct drm_dp_mst_topology_mgr *mgr, /* Skip failed payloads */ if (payload->vc_start_slot == -1) { - drm_dbg_kms(state->dev, "Part 1 of payload creation for %s failed, skipping part 2\n", + drm_dbg_kms(mgr->dev, "Part 1 of payload creation for %s failed, skipping part 2\n", payload->port->connector->name); return -EIO; } diff --git a/sys/dev/pci/drm/drm_bridge.c b/sys/dev/pci/drm/drm_bridge.c index 07d698278..be8f8c952 100644 --- a/sys/dev/pci/drm/drm_bridge.c +++ b/sys/dev/pci/drm/drm_bridge.c @@ -698,6 +698,25 @@ void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, } EXPORT_SYMBOL(drm_atomic_bridge_chain_disable); +static void drm_atomic_bridge_call_post_disable(struct drm_bridge *bridge, + struct drm_atomic_state *old_state) +{ + if (old_state && bridge->funcs->atomic_post_disable) { + struct drm_bridge_state *old_bridge_state; + + old_bridge_state = + drm_atomic_get_old_bridge_state(old_state, + bridge); + if (WARN_ON(!old_bridge_state)) + return; + + bridge->funcs->atomic_post_disable(bridge, + old_bridge_state); + } else if (bridge->funcs->post_disable) { + bridge->funcs->post_disable(bridge); + } +} + /** * drm_atomic_bridge_chain_post_disable - cleans up after disabling all bridges * in the encoder chain @@ -709,36 +728,86 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_disable); * starting from the first bridge to the last. These are called after completing * &drm_encoder_helper_funcs.atomic_disable * + * If a bridge sets @pre_enable_prev_first, then the @post_disable for that + * bridge will be called before the previous one to reverse the @pre_enable + * calling direction. + * * Note: the bridge passed should be the one closest to the encoder */ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, struct drm_atomic_state *old_state) { struct drm_encoder *encoder; + struct drm_bridge *next, *limit; if (!bridge) return; encoder = bridge->encoder; + list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { - if (bridge->funcs->atomic_post_disable) { - struct drm_bridge_state *old_bridge_state; + limit = NULL; - old_bridge_state = - drm_atomic_get_old_bridge_state(old_state, - bridge); - if (WARN_ON(!old_bridge_state)) - return; + if (!list_is_last(&bridge->chain_node, &encoder->bridge_chain)) { + next = list_next_entry(bridge, chain_node); - bridge->funcs->atomic_post_disable(bridge, - old_bridge_state); - } else if (bridge->funcs->post_disable) { - bridge->funcs->post_disable(bridge); + if (next->pre_enable_prev_first) { + /* next bridge had requested that prev + * was enabled first, so disabled last + */ + limit = next; + + /* Find the next bridge that has NOT requested + * prev to be enabled first / disabled last + */ + list_for_each_entry_from(next, &encoder->bridge_chain, + chain_node) { + if (next->pre_enable_prev_first) { + next = list_prev_entry(next, chain_node); + limit = next; + break; + } + } + + /* Call these bridges in reverse order */ + list_for_each_entry_from_reverse(next, &encoder->bridge_chain, + chain_node) { + if (next == bridge) + break; + + drm_atomic_bridge_call_post_disable(next, + old_state); + } + } } + + drm_atomic_bridge_call_post_disable(bridge, old_state); + + if (limit) + /* Jump all bridges that we have already post_disabled */ + bridge = limit; } } EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable); +static void drm_atomic_bridge_call_pre_enable(struct drm_bridge *bridge, + struct drm_atomic_state *old_state) +{ + if (old_state && bridge->funcs->atomic_pre_enable) { + struct drm_bridge_state *old_bridge_state; + + old_bridge_state = + drm_atomic_get_old_bridge_state(old_state, + bridge); + if (WARN_ON(!old_bridge_state)) + return; + + bridge->funcs->atomic_pre_enable(bridge, old_bridge_state); + } else if (bridge->funcs->pre_enable) { + bridge->funcs->pre_enable(bridge); + } +} + /** * drm_atomic_bridge_chain_pre_enable - prepares for enabling all bridges in * the encoder chain @@ -750,33 +819,61 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable); * starting from the last bridge to the first. These are called before calling * &drm_encoder_helper_funcs.atomic_enable * + * If a bridge sets @pre_enable_prev_first, then the pre_enable for the + * prev bridge will be called before pre_enable of this bridge. + * * Note: the bridge passed should be the one closest to the encoder */ void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, struct drm_atomic_state *old_state) { struct drm_encoder *encoder; - struct drm_bridge *iter; + struct drm_bridge *iter, *next, *limit; if (!bridge) return; encoder = bridge->encoder; + list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { - if (iter->funcs->atomic_pre_enable) { - struct drm_bridge_state *old_bridge_state; + if (iter->pre_enable_prev_first) { + next = iter; + limit = bridge; + list_for_each_entry_from_reverse(next, + &encoder->bridge_chain, + chain_node) { + if (next == bridge) + break; - old_bridge_state = - drm_atomic_get_old_bridge_state(old_state, - iter); - if (WARN_ON(!old_bridge_state)) - return; + if (!next->pre_enable_prev_first) { + /* Found first bridge that does NOT + * request prev to be enabled first + */ + limit = list_prev_entry(next, chain_node); + break; + } + } - iter->funcs->atomic_pre_enable(iter, old_bridge_state); - } else if (iter->funcs->pre_enable) { - iter->funcs->pre_enable(iter); + list_for_each_entry_from(next, &encoder->bridge_chain, chain_node) { + /* Call requested prev bridge pre_enable + * in order. + */ + if (next == iter) + /* At the first bridge to request prev + * bridges called first. + */ + break; + + drm_atomic_bridge_call_pre_enable(next, old_state); + } } + drm_atomic_bridge_call_pre_enable(iter, old_state); + + if (iter->pre_enable_prev_first) + /* Jump all bridges that we have already pre_enabled */ + iter = limit; + if (iter == bridge) break; } diff --git a/sys/dev/pci/drm/drm_gem.c b/sys/dev/pci/drm/drm_gem.c index b91420bf2..fb701923f 100644 --- a/sys/dev/pci/drm/drm_gem.c +++ b/sys/dev/pci/drm/drm_gem.c @@ -102,7 +102,7 @@ drm_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, vm_page_t *pps, * we do not allow device mappings to be mapped copy-on-write * so we kill any attempt to do so here. */ - + if (UVM_ET_ISCOPYONWRITE(entry)) { uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj); return(VM_PAGER_ERROR); @@ -144,7 +144,7 @@ drm_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, vm_page_t *pps, return (ret); } -boolean_t +boolean_t drm_flush(struct uvm_object *uobj, voff_t start, voff_t stop, int flags) { return (TRUE); @@ -309,10 +309,10 @@ int drm_gem_object_init(struct drm_device *dev, printf("%s size too big %lu\n", __func__, size); return -ENOMEM; } - + obj->uao = uao_create(size, 0); uvm_obj_init(&obj->uobj, &drm_pgops, 1); - + return 0; } diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index d710aebc5..61139ea77 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.99 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.101 2023/07/18 06:58:59 claudio Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -98,30 +98,30 @@ tasklet_run(void *arg) struct mutex atomic64_mtx = MUTEX_INITIALIZER(IPL_HIGH); #endif -struct mutex sch_mtx = MUTEX_INITIALIZER(IPL_SCHED); -volatile struct proc *sch_proc; -volatile void *sch_ident; -int sch_priority; - void set_current_state(int state) { - if (sch_ident != curproc) - mtx_enter(&sch_mtx); - MUTEX_ASSERT_LOCKED(&sch_mtx); - sch_ident = sch_proc = curproc; - sch_priority = state; + int prio = state; + + KASSERT(state != TASK_RUNNING); + /* check if already on the sleep list */ + if (curproc->p_wchan != NULL) + return; + sleep_setup(curproc, prio, "schto"); } void __set_current_state(int state) { + struct proc *p = curproc; + int s; + KASSERT(state == TASK_RUNNING); - if (sch_ident == curproc) { - MUTEX_ASSERT_LOCKED(&sch_mtx); - sch_ident = NULL; - mtx_leave(&sch_mtx); - } + SCHED_LOCK(s); + unsleep(p); + p->p_stat = SONPROC; + atomic_clearbits_int(&p->p_flag, P_WSLEEP); + SCHED_UNLOCK(s); } void @@ -133,34 +133,19 @@ schedule(void) long schedule_timeout(long timeout) { - struct sleep_state sls; unsigned long deadline; - int wait, spl, prio, timo = 0; + int timo = 0; - MUTEX_ASSERT_LOCKED(&sch_mtx); KASSERT(!cold); if (timeout != MAX_SCHEDULE_TIMEOUT) timo = timeout; - prio = sch_priority; - sleep_setup(&sls, sch_ident, prio, "schto"); - - wait = (sch_proc == curproc && timeout > 0); - - spl = MUTEX_OLDIPL(&sch_mtx); - MUTEX_OLDIPL(&sch_mtx) = splsched(); - mtx_leave(&sch_mtx); - if (timeout != MAX_SCHEDULE_TIMEOUT) deadline = jiffies + timeout; - sleep_finish(&sls, prio, timo, wait); + sleep_finish(timo, timeout > 0); if (timeout != MAX_SCHEDULE_TIMEOUT) timeout = deadline - jiffies; - mtx_enter(&sch_mtx); - MUTEX_OLDIPL(&sch_mtx) = spl; - sch_ident = curproc; - return timeout > 0 ? timeout : 0; } @@ -177,12 +162,43 @@ wake_up_process(struct proc *p) int s, rv; SCHED_LOCK(s); - atomic_cas_ptr(&sch_proc, p, NULL); rv = wakeup_proc(p, NULL, 0); SCHED_UNLOCK(s); return rv; } +int +autoremove_wake_function(struct wait_queue_entry *wqe, unsigned int mode, + int sync, void *key) +{ + if (wqe->private) + wake_up_process(wqe->private); + list_del_init(&wqe->entry); + return 0; +} + +void +prepare_to_wait(wait_queue_head_t *wqh, wait_queue_entry_t *wqe, int state) +{ + mtx_enter(&wqh->lock); + if (list_empty(&wqe->entry)) + __add_wait_queue(wqh, wqe); + mtx_leave(&wqh->lock); + + set_current_state(state); +} + +void +finish_wait(wait_queue_head_t *wqh, wait_queue_entry_t *wqe) +{ + __set_current_state(TASK_RUNNING); + + mtx_enter(&wqh->lock); + if (!list_empty(&wqe->entry)) + list_del_init(&wqe->entry); + mtx_leave(&wqh->lock); +} + void flush_workqueue(struct workqueue_struct *wq) { @@ -257,7 +273,7 @@ kthread_run(int (*func)(void *), void *data, const char *name) thread->func = func; thread->data = data; thread->flags = 0; - + if (kthread_create(kthread_func, thread, &thread->proc, name)) { free(thread, M_DRM, sizeof(*thread)); return ERR_PTR(-ENOMEM); @@ -278,7 +294,7 @@ kthread_create_worker(unsigned int flags, const char *fmt, ...) vsnprintf(name, sizeof(name), fmt, ap); va_end(ap); w->tq = taskq_create(name, 1, IPL_HIGH, 0); - + return w; } @@ -287,7 +303,7 @@ kthread_destroy_worker(struct kthread_worker *worker) { taskq_destroy(worker->tq); free(worker, M_DRM, sizeof(*worker)); - + } void @@ -557,7 +573,7 @@ __free_pages(struct vm_page *page, unsigned int order) { struct pglist mlist; int i; - + TAILQ_INIT(&mlist); for (i = 0; i < (1 << order); i++) TAILQ_INSERT_TAIL(&mlist, &page[i], pageq); @@ -629,7 +645,7 @@ void kunmap_atomic(void *addr) { KASSERT(kmap_atomic_inuse); - + pmap_kremove(kmap_atomic_va, PAGE_SIZE); kmap_atomic_inuse = 0; } @@ -1199,7 +1215,7 @@ retry: int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - int ret; + int ret; if (adap->lock_ops) adap->lock_ops->lock_bus(adap, 0); @@ -1503,7 +1519,7 @@ backlight_device_register(const char *name, void *kdev, void *data, bd->data = data; task_set(&bd->task, backlight_do_update_status, bd); - + return bd; } @@ -1726,7 +1742,7 @@ dma_fence_wait(struct dma_fence *fence, bool intr) ret = dma_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT); if (ret < 0) return ret; - + return 0; } @@ -1886,7 +1902,7 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) list_del(&cb.base.node); out: mtx_leave(fence->lock); - + return ret; } @@ -1932,7 +1948,7 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count, cb = mallocarray(count, sizeof(*cb), M_DRM, M_WAITOK|M_CANFAIL|M_ZERO); if (cb == NULL) return -ENOMEM; - + for (i = 0; i < count; i++) { struct dma_fence *fence = fences[i]; cb[i].proc = curproc; @@ -2028,7 +2044,7 @@ dma_fence_array_cb_func(struct dma_fence *f, struct dma_fence_cb *cb) struct dma_fence_array_cb *array_cb = container_of(cb, struct dma_fence_array_cb, cb); struct dma_fence_array *dfa = array_cb->array; - + if (atomic_dec_and_test(&dfa->num_pending)) timeout_add(&dfa->to, 1); else @@ -2052,7 +2068,7 @@ dma_fence_array_enable_signaling(struct dma_fence *fence) return false; } } - + return true; } @@ -2532,7 +2548,7 @@ pcie_get_speed_cap(struct pci_dev *pdev) tag = pdev->tag; if (!pci_get_capability(pc, tag, PCI_CAP_PCIEXPRESS, - &pos, NULL)) + &pos, NULL)) return PCI_SPEED_UNKNOWN; id = pci_conf_read(pc, tag, PCI_ID_REG); @@ -2588,7 +2604,7 @@ pcie_get_width_cap(struct pci_dev *pdev) int bus, device, function; if (!pci_get_capability(pc, tag, PCI_CAP_PCIEXPRESS, - &pos, NULL)) + &pos, NULL)) return PCIE_LNK_WIDTH_UNKNOWN; id = pci_conf_read(pc, tag, PCI_ID_REG); @@ -2613,25 +2629,14 @@ pcie_aspm_enabled(struct pci_dev *pdev) pcireg_t lcsr; if (!pci_get_capability(pc, tag, PCI_CAP_PCIEXPRESS, - &pos, NULL)) + &pos, NULL)) return false; lcsr = pci_conf_read(pc, tag, pos + PCI_PCIE_LCSR); if ((lcsr & (PCI_PCIE_LCSR_ASPM_L0S | PCI_PCIE_LCSR_ASPM_L1)) != 0) return true; - - return false; -} -int -autoremove_wake_function(struct wait_queue_entry *wqe, unsigned int mode, - int sync, void *key) -{ - wakeup(wqe); - if (wqe->private) - wake_up_process(wqe->private); - list_del_init(&wqe->entry); - return 0; + return false; } static wait_queue_head_t bit_waitq; @@ -2902,7 +2907,7 @@ interval_tree_iter_first(struct rb_root_cached *root, unsigned long start, void interval_tree_remove(struct interval_tree_node *node, - struct rb_root_cached *root) + struct rb_root_cached *root) { rb_erase_cached(&node->rb, root); } @@ -3027,7 +3032,7 @@ fput(struct file *fp) { if (fp->f_type != DTYPE_SYNC) return; - + FRELE(fp, curproc); } diff --git a/sys/dev/pci/drm/drm_lock.c b/sys/dev/pci/drm/drm_lock.c index 1efbd5389..168c977ca 100644 --- a/sys/dev/pci/drm/drm_lock.c +++ b/sys/dev/pci/drm/drm_lock.c @@ -223,7 +223,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data, ret ? "interrupted" : "has lock"); if (ret) return ret; - /* don't set the block all signals on the master process for now + /* don't set the block all signals on the master process for now * really probably not the correct answer but lets us debug xkb * xserver for now */ if (!drm_is_current_master(file_priv)) { diff --git a/sys/dev/pci/drm/drm_managed.c b/sys/dev/pci/drm/drm_managed.c index 5f5176672..003a1e112 100644 --- a/sys/dev/pci/drm/drm_managed.c +++ b/sys/dev/pci/drm/drm_managed.c @@ -95,7 +95,7 @@ drmm_kfree(struct drm_device *dev, void *p) } } mtx_leave(&dev->managed.lock); - + if (m != NULL) { free(m->p, M_DRM, m->size); free(m, M_DRM, sizeof(*m)); diff --git a/sys/dev/pci/drm/drm_mm.c b/sys/dev/pci/drm/drm_mm.c index 17c3fffcd..b3b1a355c 100644 --- a/sys/dev/pci/drm/drm_mm.c +++ b/sys/dev/pci/drm/drm_mm.c @@ -174,7 +174,7 @@ drm_mm_interval_tree_iter_first(const struct rb_root_cached *root, static void drm_mm_interval_tree_remove(struct drm_mm_node *node, - struct rb_root_cached *root) + struct rb_root_cached *root) { rb_erase_cached(&node->rb, root); } diff --git a/sys/dev/pci/drm/i915/display/intel_ddi.c b/sys/dev/pci/drm/i915/display/intel_ddi.c index 895d1bec1..c15efed61 100644 --- a/sys/dev/pci/drm/i915/display/intel_ddi.c +++ b/sys/dev/pci/drm/i915/display/intel_ddi.c @@ -3579,7 +3579,7 @@ static void intel_ddi_sync_state(struct intel_encoder *encoder, enum phy phy = intel_port_to_phy(i915, encoder->port); if (intel_phy_is_tc(i915, phy)) - intel_tc_port_sanitize(enc_to_dig_port(encoder)); + intel_tc_port_sanitize_mode(enc_to_dig_port(encoder)); if (crtc_state && intel_crtc_has_dp_encoder(crtc_state)) intel_dp_sync_state(encoder, crtc_state); @@ -3789,11 +3789,17 @@ static void intel_ddi_encoder_destroy(struct drm_encoder *encoder) static void intel_ddi_encoder_reset(struct drm_encoder *encoder) { + struct drm_i915_private *i915 = to_i915(encoder->dev); struct intel_dp *intel_dp = enc_to_intel_dp(to_intel_encoder(encoder)); + struct intel_digital_port *dig_port = enc_to_dig_port(to_intel_encoder(encoder)); + enum phy phy = intel_port_to_phy(i915, dig_port->base.port); intel_dp->reset_link_params = true; intel_pps_encoder_reset(intel_dp); + + if (intel_phy_is_tc(i915, phy)) + intel_tc_port_init_mode(dig_port); } static const struct drm_encoder_funcs intel_ddi_funcs = { diff --git a/sys/dev/pci/drm/i915/display/intel_display_types.h b/sys/dev/pci/drm/i915/display/intel_display_types.h index bdc5d5e21..73bdbe55b 100644 --- a/sys/dev/pci/drm/i915/display/intel_display_types.h +++ b/sys/dev/pci/drm/i915/display/intel_display_types.h @@ -1763,6 +1763,7 @@ struct intel_digital_port { bool tc_legacy_port:1; char tc_port_name[8]; enum tc_port_mode tc_mode; + enum tc_port_mode tc_init_mode; enum phy_fia tc_phy_fia; u8 tc_phy_fia_idx; diff --git a/sys/dev/pci/drm/i915/display/intel_psr.c b/sys/dev/pci/drm/i915/display/intel_psr.c index b02f5b213..f1e3845b9 100644 --- a/sys/dev/pci/drm/i915/display/intel_psr.c +++ b/sys/dev/pci/drm/i915/display/intel_psr.c @@ -857,9 +857,9 @@ static bool _compute_psr2_wake_times(struct intel_dp *intel_dp, } io_wake_lines = intel_usecs_to_scanlines( - &crtc_state->uapi.adjusted_mode, io_wake_time); + &crtc_state->hw.adjusted_mode, io_wake_time); fast_wake_lines = intel_usecs_to_scanlines( - &crtc_state->uapi.adjusted_mode, fast_wake_time); + &crtc_state->hw.adjusted_mode, fast_wake_time); if (io_wake_lines > max_wake_lines || fast_wake_lines > max_wake_lines) diff --git a/sys/dev/pci/drm/i915/display/intel_tc.c b/sys/dev/pci/drm/i915/display/intel_tc.c index 38e22b050..04450f10f 100644 --- a/sys/dev/pci/drm/i915/display/intel_tc.c +++ b/sys/dev/pci/drm/i915/display/intel_tc.c @@ -5,6 +5,7 @@ #include "i915_drv.h" #include "i915_reg.h" +#include "intel_de.h" #include "intel_display.h" #include "intel_display_power_map.h" #include "intel_display_types.h" @@ -116,6 +117,24 @@ assert_tc_cold_blocked(struct intel_digital_port *dig_port) drm_WARN_ON(&i915->drm, !enabled); } +static enum intel_display_power_domain +tc_port_power_domain(struct intel_digital_port *dig_port) +{ + struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); + enum tc_port tc_port = intel_port_to_tc(i915, dig_port->base.port); + + return POWER_DOMAIN_PORT_DDI_LANES_TC1 + tc_port - TC_PORT_1; +} + +static void +assert_tc_port_power_enabled(struct intel_digital_port *dig_port) +{ + struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); + + drm_WARN_ON(&i915->drm, + !intel_display_power_is_enabled(i915, tc_port_power_domain(dig_port))); +} + u32 intel_tc_port_get_lane_mask(struct intel_digital_port *dig_port) { struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); @@ -683,22 +702,89 @@ static void intel_tc_port_update_mode(struct intel_digital_port *dig_port, tc_cold_unblock(dig_port, domain, wref); } -static void -intel_tc_port_link_init_refcount(struct intel_digital_port *dig_port, - int refcount) +static void __intel_tc_port_get_link(struct intel_digital_port *dig_port) +{ + dig_port->tc_link_refcount++; +} + +static void __intel_tc_port_put_link(struct intel_digital_port *dig_port) +{ + dig_port->tc_link_refcount--; +} + +static bool tc_port_is_enabled(struct intel_digital_port *dig_port) { struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); - drm_WARN_ON(&i915->drm, dig_port->tc_link_refcount); - dig_port->tc_link_refcount = refcount; + assert_tc_port_power_enabled(dig_port); + + return intel_de_read(i915, DDI_BUF_CTL(dig_port->base.port)) & + DDI_BUF_CTL_ENABLE; } -void intel_tc_port_sanitize(struct intel_digital_port *dig_port) +/** + * intel_tc_port_init_mode: Read out HW state and init the given port's TypeC mode + * @dig_port: digital port + * + * Read out the HW state and initialize the TypeC mode of @dig_port. The mode + * will be locked until intel_tc_port_sanitize_mode() is called. + */ +void intel_tc_port_init_mode(struct intel_digital_port *dig_port) +{ + struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); + intel_wakeref_t tc_cold_wref; + enum intel_display_power_domain domain; + + mutex_lock(&dig_port->tc_lock); + + drm_WARN_ON(&i915->drm, dig_port->tc_mode != TC_PORT_DISCONNECTED); + drm_WARN_ON(&i915->drm, dig_port->tc_lock_wakeref); + drm_WARN_ON(&i915->drm, dig_port->tc_link_refcount); + + tc_cold_wref = tc_cold_block(dig_port, &domain); + + dig_port->tc_mode = intel_tc_port_get_current_mode(dig_port); + /* + * Save the initial mode for the state check in + * intel_tc_port_sanitize_mode(). + */ + dig_port->tc_init_mode = dig_port->tc_mode; + dig_port->tc_lock_wakeref = tc_cold_block(dig_port, &dig_port->tc_lock_power_domain); + + /* + * The PHY needs to be connected for AUX to work during HW readout and + * MST topology resume, but the PHY mode can only be changed if the + * port is disabled. + */ + if (!tc_port_is_enabled(dig_port)) + intel_tc_port_update_mode(dig_port, 1, false); + + /* Prevent changing dig_port->tc_mode until intel_tc_port_sanitize_mode() is called. */ + __intel_tc_port_get_link(dig_port); + + tc_cold_unblock(dig_port, domain, tc_cold_wref); + + drm_dbg_kms(&i915->drm, "Port %s: init mode (%s)\n", + dig_port->tc_port_name, + tc_port_mode_name(dig_port->tc_mode)); + + mutex_unlock(&dig_port->tc_lock); +} + +/** + * intel_tc_port_sanitize_mode: Sanitize the given port's TypeC mode + * @dig_port: digital port + * + * Sanitize @dig_port's TypeC mode wrt. the encoder's state right after driver + * loading and system resume: + * If the encoder is enabled keep the TypeC mode/PHY connected state locked until + * the encoder is disabled. + * If the encoder is disabled make sure the PHY is disconnected. + */ +void intel_tc_port_sanitize_mode(struct intel_digital_port *dig_port) { struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); struct intel_encoder *encoder = &dig_port->base; - intel_wakeref_t tc_cold_wref; - enum intel_display_power_domain domain; int active_links = 0; mutex_lock(&dig_port->tc_lock); @@ -708,21 +794,12 @@ void intel_tc_port_sanitize(struct intel_digital_port *dig_port) else if (encoder->base.crtc) active_links = to_intel_crtc(encoder->base.crtc)->active; - drm_WARN_ON(&i915->drm, dig_port->tc_mode != TC_PORT_DISCONNECTED); - drm_WARN_ON(&i915->drm, dig_port->tc_lock_wakeref); - - tc_cold_wref = tc_cold_block(dig_port, &domain); - - dig_port->tc_mode = intel_tc_port_get_current_mode(dig_port); + drm_WARN_ON(&i915->drm, dig_port->tc_link_refcount != 1); if (active_links) { if (!icl_tc_phy_is_connected(dig_port)) drm_dbg_kms(&i915->drm, "Port %s: PHY disconnected with %d active link(s)\n", dig_port->tc_port_name, active_links); - intel_tc_port_link_init_refcount(dig_port, active_links); - - dig_port->tc_lock_wakeref = tc_cold_block(dig_port, - &dig_port->tc_lock_power_domain); } else { /* * TBT-alt is the default mode in any case the PHY ownership is not @@ -730,15 +807,17 @@ void intel_tc_port_sanitize(struct intel_digital_port *dig_port) * we'll just switch to disconnected mode from it here without * a note. */ - if (dig_port->tc_mode != TC_PORT_TBT_ALT) + if (dig_port->tc_init_mode != TC_PORT_TBT_ALT) drm_dbg_kms(&i915->drm, "Port %s: PHY left in %s mode on disabled port, disconnecting it\n", dig_port->tc_port_name, - tc_port_mode_name(dig_port->tc_mode)); + tc_port_mode_name(dig_port->tc_init_mode)); icl_tc_phy_disconnect(dig_port); - } + __intel_tc_port_put_link(dig_port); - tc_cold_unblock(dig_port, domain, tc_cold_wref); + tc_cold_unblock(dig_port, dig_port->tc_lock_power_domain, + fetch_and_zero(&dig_port->tc_lock_wakeref)); + } drm_dbg_kms(&i915->drm, "Port %s: sanitize mode (%s)\n", dig_port->tc_port_name, @@ -846,14 +925,14 @@ void intel_tc_port_get_link(struct intel_digital_port *dig_port, int required_lanes) { __intel_tc_port_lock(dig_port, required_lanes); - dig_port->tc_link_refcount++; + __intel_tc_port_get_link(dig_port); intel_tc_port_unlock(dig_port); } void intel_tc_port_put_link(struct intel_digital_port *dig_port) { intel_tc_port_lock(dig_port); - --dig_port->tc_link_refcount; + __intel_tc_port_put_link(dig_port); intel_tc_port_unlock(dig_port); /* @@ -923,4 +1002,6 @@ void intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy) dig_port->tc_mode = TC_PORT_DISCONNECTED; dig_port->tc_link_refcount = 0; tc_port_load_fia_params(i915, dig_port); + + intel_tc_port_init_mode(dig_port); } diff --git a/sys/dev/pci/drm/i915/display/intel_tc.h b/sys/dev/pci/drm/i915/display/intel_tc.h index 6b47b29f5..d54082e2d 100644 --- a/sys/dev/pci/drm/i915/display/intel_tc.h +++ b/sys/dev/pci/drm/i915/display/intel_tc.h @@ -24,7 +24,8 @@ int intel_tc_port_fia_max_lane_count(struct intel_digital_port *dig_port); void intel_tc_port_set_fia_lane_count(struct intel_digital_port *dig_port, int required_lanes); -void intel_tc_port_sanitize(struct intel_digital_port *dig_port); +void intel_tc_port_init_mode(struct intel_digital_port *dig_port); +void intel_tc_port_sanitize_mode(struct intel_digital_port *dig_port); void intel_tc_port_lock(struct intel_digital_port *dig_port); void intel_tc_port_unlock(struct intel_digital_port *dig_port); void intel_tc_port_flush_work(struct intel_digital_port *dig_port); diff --git a/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c b/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c index 5b3d56e7d..0a52e575f 100644 --- a/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c +++ b/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c @@ -177,7 +177,7 @@ intel_gmch_gtt_get(u64 *gtt_total, { struct inteldrm_softc *dev_priv = (void *)inteldrm_cd.cd_devs[0]; struct agp_info *ai = &dev_priv->drm.agp->info; - + *gtt_total = ai->ai_aperture_size; *mappable_base = ai->ai_aperture_base; *mappable_end = ai->ai_aperture_size; diff --git a/sys/dev/pci/drm/i915/gt/shmem_utils.c b/sys/dev/pci/drm/i915/gt/shmem_utils.c index d41ffb782..193f110f1 100644 --- a/sys/dev/pci/drm/i915/gt/shmem_utils.c +++ b/sys/dev/pci/drm/i915/gt/shmem_utils.c @@ -228,7 +228,7 @@ static int __uao_rw(struct uvm_object *uao, loff_t off, unsigned int this = min_t(size_t, PAGE_SIZE - offset_in_page(off), len); void *vaddr = kmap(page); - + if (write) { memcpy(vaddr + offset_in_page(off), ptr, this); set_page_dirty(page); diff --git a/sys/dev/pci/drm/i915/gt/uc/intel_guc_slpc.c b/sys/dev/pci/drm/i915/gt/uc/intel_guc_slpc.c index ebd2893d2..c0cb06faa 100644 --- a/sys/dev/pci/drm/i915/gt/uc/intel_guc_slpc.c +++ b/sys/dev/pci/drm/i915/gt/uc/intel_guc_slpc.c @@ -580,7 +580,7 @@ static int slpc_set_softlimits(struct intel_guc_slpc *slpc) if (unlikely(ret)) return ret; slpc_to_gt(slpc)->defaults.min_freq = slpc->min_freq_softlimit; - } else if (slpc->min_freq_softlimit != slpc->min_freq) { + } else { return intel_guc_slpc_set_min_freq(slpc, slpc->min_freq_softlimit); } diff --git a/sys/dev/pci/drm/include/drm/drm_bridge.h b/sys/dev/pci/drm/include/drm/drm_bridge.h index 3f39d3532..81545c053 100644 --- a/sys/dev/pci/drm/include/drm/drm_bridge.h +++ b/sys/dev/pci/drm/include/drm/drm_bridge.h @@ -768,6 +768,14 @@ struct drm_bridge { * modes. */ bool interlace_allowed; + /** + * @pre_enable_prev_first: The bridge requires that the prev + * bridge @pre_enable function is called before its @pre_enable, + * and conversely for post_disable. This is most frequently a + * requirement for DSI devices which need the host to be initialised + * before the peripheral. + */ + bool pre_enable_prev_first; /** * @ddc: Associated I2C adapter for DDC access, if any. */ diff --git a/sys/dev/pci/drm/include/drm/drm_fixed.h b/sys/dev/pci/drm/include/drm/drm_fixed.h index 553210c02..03cb89069 100644 --- a/sys/dev/pci/drm/include/drm/drm_fixed.h +++ b/sys/dev/pci/drm/include/drm/drm_fixed.h @@ -70,6 +70,7 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B) } #define DRM_FIXED_POINT 32 +#define DRM_FIXED_POINT_HALF 16 #define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT) #define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1) #define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK) @@ -86,6 +87,11 @@ static inline int drm_fixp2int(s64 a) return ((s64)a) >> DRM_FIXED_POINT; } +static inline int drm_fixp2int_round(s64 a) +{ + return drm_fixp2int(a + (1 << (DRM_FIXED_POINT_HALF - 1))); +} + static inline int drm_fixp2int_ceil(s64 a) { if (a > 0) diff --git a/sys/dev/pci/drm/include/linux/atomic.h b/sys/dev/pci/drm/include/linux/atomic.h index fb785a0c9..3e13af4dc 100644 --- a/sys/dev/pci/drm/include/linux/atomic.h +++ b/sys/dev/pci/drm/include/linux/atomic.h @@ -2,7 +2,7 @@ /** * \file drm_atomic.h * Atomic operations used in the DRM which may or may not be provided by the OS. - * + * * \author Eric Anholt */ @@ -298,7 +298,7 @@ __test_and_set_bit(u_int b, volatile void *p) volatile u_int *ptr = (volatile u_int *)p; unsigned int prev = ptr[b >> 5]; ptr[b >> 5] |= m; - + return (prev & m) != 0; } @@ -428,7 +428,7 @@ find_next_bit(const volatile void *p, int max, int b) #define wmb() __membar("dsb sy") #define mb() __membar("dsb sy") #elif defined(__mips64__) -#define rmb() mips_sync() +#define rmb() mips_sync() #define wmb() mips_sync() #define mb() mips_sync() #elif defined(__powerpc64__) diff --git a/sys/dev/pci/drm/include/linux/capability.h b/sys/dev/pci/drm/include/linux/capability.h index c91b233d9..5accf04f7 100644 --- a/sys/dev/pci/drm/include/linux/capability.h +++ b/sys/dev/pci/drm/include/linux/capability.h @@ -12,8 +12,8 @@ #define CAP_SYS_NICE 0x2 static inline bool -capable(int cap) -{ +capable(int cap) +{ switch (cap) { case CAP_SYS_ADMIN: case CAP_SYS_NICE: @@ -21,7 +21,7 @@ capable(int cap) default: panic("unhandled capability"); } -} +} static inline bool perfmon_capable(void) diff --git a/sys/dev/pci/drm/include/linux/dma-buf.h b/sys/dev/pci/drm/include/linux/dma-buf.h index 32f05c309..f789e8d20 100644 --- a/sys/dev/pci/drm/include/linux/dma-buf.h +++ b/sys/dev/pci/drm/include/linux/dma-buf.h @@ -61,7 +61,7 @@ struct dma_buf_export_info { struct dma_resv *resv; }; -#define DEFINE_DMA_BUF_EXPORT_INFO(x) struct dma_buf_export_info x +#define DEFINE_DMA_BUF_EXPORT_INFO(x) struct dma_buf_export_info x struct dma_buf *dma_buf_export(const struct dma_buf_export_info *); diff --git a/sys/dev/pci/drm/include/linux/file.h b/sys/dev/pci/drm/include/linux/file.h index f59981db1..e27bfaddf 100644 --- a/sys/dev/pci/drm/include/linux/file.h +++ b/sys/dev/pci/drm/include/linux/file.h @@ -4,7 +4,7 @@ #define _LINUX_FILE_H /* both for printf */ -#include +#include #include void fd_install(int, struct file *); diff --git a/sys/dev/pci/drm/include/linux/interrupt.h b/sys/dev/pci/drm/include/linux/interrupt.h index b555183c9..13a154522 100644 --- a/sys/dev/pci/drm/include/linux/interrupt.h +++ b/sys/dev/pci/drm/include/linux/interrupt.h @@ -106,7 +106,7 @@ tasklet_hi_schedule(struct tasklet_struct *ts) task_add(taskletq, &ts->task); } -static inline void +static inline void tasklet_disable_nosync(struct tasklet_struct *ts) { atomic_inc(&ts->count); diff --git a/sys/dev/pci/drm/include/linux/io.h b/sys/dev/pci/drm/include/linux/io.h index 08e20aa0c..201772580 100644 --- a/sys/dev/pci/drm/include/linux/io.h +++ b/sys/dev/pci/drm/include/linux/io.h @@ -119,7 +119,7 @@ static inline u32 ioread32(const volatile void __iomem *addr) { uint32_t val; - + iobarrier(); val = lemtoh32(addr); rmb(); diff --git a/sys/dev/pci/drm/include/linux/pci.h b/sys/dev/pci/drm/include/linux/pci.h index 3f8de6b86..1021bb7ee 100644 --- a/sys/dev/pci/drm/include/linux/pci.h +++ b/sys/dev/pci/drm/include/linux/pci.h @@ -135,7 +135,7 @@ pci_read_config_dword(struct pci_dev *pdev, int reg, u32 *val) { *val = pci_conf_read(pdev->pc, pdev->tag, reg); return 0; -} +} static inline int pci_read_config_word(struct pci_dev *pdev, int reg, u16 *val) @@ -145,7 +145,7 @@ pci_read_config_word(struct pci_dev *pdev, int reg, u16 *val) v = pci_conf_read(pdev->pc, pdev->tag, (reg & ~0x2)); *val = (v >> ((reg & 0x2) * 8)); return 0; -} +} static inline int pci_read_config_byte(struct pci_dev *pdev, int reg, u8 *val) @@ -155,14 +155,14 @@ pci_read_config_byte(struct pci_dev *pdev, int reg, u8 *val) v = pci_conf_read(pdev->pc, pdev->tag, (reg & ~0x3)); *val = (v >> ((reg & 0x3) * 8)); return 0; -} +} static inline int pci_write_config_dword(struct pci_dev *pdev, int reg, u32 val) { pci_conf_write(pdev->pc, pdev->tag, reg, val); return 0; -} +} static inline int pci_write_config_word(struct pci_dev *pdev, int reg, u16 val) @@ -174,7 +174,7 @@ pci_write_config_word(struct pci_dev *pdev, int reg, u16 val) v |= (val << ((reg & 0x2) * 8)); pci_conf_write(pdev->pc, pdev->tag, (reg & ~0x2), v); return 0; -} +} static inline int pci_write_config_byte(struct pci_dev *pdev, int reg, u8 val) @@ -319,7 +319,7 @@ static inline int pcie_set_readrq(struct pci_dev *pdev, int rrq) { uint16_t val; - + pcie_capability_read_word(pdev, PCI_PCIE_DCSR, &val); val &= ~PCI_PCIE_DCSR_MPS; val |= (ffs(rrq) - 8) << 12; diff --git a/sys/dev/pci/drm/include/linux/rbtree.h b/sys/dev/pci/drm/include/linux/rbtree.h index 39d013afd..40cbdf7fb 100644 --- a/sys/dev/pci/drm/include/linux/rbtree.h +++ b/sys/dev/pci/drm/include/linux/rbtree.h @@ -99,7 +99,7 @@ __rb_deepest_left(struct rb_node *node) else node = RB_RIGHT(node, __entry); } - return parent; + return parent; } static inline struct rb_node * diff --git a/sys/dev/pci/drm/include/linux/scatterlist.h b/sys/dev/pci/drm/include/linux/scatterlist.h index b2c0cb50d..afbb0180a 100644 --- a/sys/dev/pci/drm/include/linux/scatterlist.h +++ b/sys/dev/pci/drm/include/linux/scatterlist.h @@ -77,7 +77,7 @@ static inline bool __sg_page_iter_next(struct sg_page_iter *iter) { iter->sg_pgoffset++; - while (iter->__nents > 0 && + while (iter->__nents > 0 && iter->sg_pgoffset >= (iter->sg->length / PAGE_SIZE)) { iter->sg_pgoffset -= (iter->sg->length / PAGE_SIZE); iter->sg++; diff --git a/sys/dev/pci/drm/include/linux/seqlock.h b/sys/dev/pci/drm/include/linux/seqlock.h index e3dabf2c9..f2d0f9dd8 100644 --- a/sys/dev/pci/drm/include/linux/seqlock.h +++ b/sys/dev/pci/drm/include/linux/seqlock.h @@ -91,7 +91,7 @@ typedef struct { static inline void seqlock_init(seqlock_t *sl, int wantipl) -{ +{ sl->seq = 0; mtx_init(&sl->lock, wantipl); } diff --git a/sys/dev/pci/drm/include/linux/string.h b/sys/dev/pci/drm/include/linux/string.h index f76ddf6f6..6dc172235 100644 --- a/sys/dev/pci/drm/include/linux/string.h +++ b/sys/dev/pci/drm/include/linux/string.h @@ -74,7 +74,7 @@ match_string(const char * const *array, size_t n, const char *str) for (i = 0; i < n; i++) { if (array[i] == NULL) break; - if (!strcmp(array[i], str)) + if (!strcmp(array[i], str)) return i; } diff --git a/sys/dev/pci/drm/include/linux/swap.h b/sys/dev/pci/drm/include/linux/swap.h index dcfb9c9d1..7a16f8006 100644 --- a/sys/dev/pci/drm/include/linux/swap.h +++ b/sys/dev/pci/drm/include/linux/swap.h @@ -30,11 +30,11 @@ static inline long get_nr_swap_pages(void) -{ +{ return uvmexp.swpages - uvmexp.swpginuse; } -/* +/* * XXX For now, we don't want the shrinker to be too aggressive, so * pretend we're not called from the pagedaemon even if we are. */ diff --git a/sys/dev/pci/drm/include/linux/wait.h b/sys/dev/pci/drm/include/linux/wait.h index 758c0b1e5..6ac025d07 100644 --- a/sys/dev/pci/drm/include/linux/wait.h +++ b/sys/dev/pci/drm/include/linux/wait.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wait.h,v 1.9 2023/01/01 01:34:58 jsg Exp $ */ +/* $OpenBSD: wait.h,v 1.10 2023/07/18 06:58:59 claudio Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2017 Martin Pieuchot @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -36,17 +37,15 @@ struct wait_queue_entry { typedef struct wait_queue_entry wait_queue_entry_t; -extern struct mutex sch_mtx; -extern volatile struct proc *sch_proc; -extern volatile void *sch_ident; -extern int sch_priority; - struct wait_queue_head { struct mutex lock; struct list_head head; }; typedef struct wait_queue_head wait_queue_head_t; +void prepare_to_wait(wait_queue_head_t *, wait_queue_entry_t *, int); +void finish_wait(wait_queue_head_t *, wait_queue_entry_t *); + static inline void init_waitqueue_head(wait_queue_head_t *wqh) { @@ -103,30 +102,36 @@ remove_wait_queue(wait_queue_head_t *head, wait_queue_entry_t *old) #define __wait_event_intr_timeout(wqh, condition, timo, prio) \ ({ \ - long ret = timo; \ + long __ret = timo; \ + struct wait_queue_entry __wq_entry; \ + \ + init_wait_entry(&__wq_entry, 0); \ do { \ - int __error; \ + int __error, __wait; \ unsigned long deadline; \ \ KASSERT(!cold); \ \ - mtx_enter(&sch_mtx); \ - deadline = jiffies + ret; \ - __error = msleep(&wqh, &sch_mtx, prio, "drmweti", ret); \ - ret = deadline - jiffies; \ + prepare_to_wait(&wqh, &__wq_entry, prio); \ + deadline = jiffies + __ret; \ + \ + __wait = !(condition); \ + \ + __error = sleep_finish(__ret, __wait); \ + if ((timo) > 0) \ + __ret = deadline - jiffies; \ + \ if (__error == ERESTART || __error == EINTR) { \ - ret = -ERESTARTSYS; \ - mtx_leave(&sch_mtx); \ + __ret = -ERESTARTSYS; \ break; \ } \ - if ((timo) > 0 && (ret <= 0 || __error == EWOULDBLOCK)) { \ - mtx_leave(&sch_mtx); \ - ret = ((condition)) ? 1 : 0; \ + if ((timo) > 0 && (__ret <= 0 || __error == EWOULDBLOCK)) { \ + __ret = ((condition)) ? 1 : 0; \ break; \ } \ - mtx_leave(&sch_mtx); \ - } while (ret > 0 && !(condition)); \ - ret; \ + } while (__ret > 0 && !(condition)); \ + finish_wait(&wqh, &__wq_entry); \ + __ret; \ }) /* @@ -194,15 +199,23 @@ do { \ #define __wait_event_lock_irq(wqh, condition, mtx) \ ({ \ + struct wait_queue_entry __wq_entry; \ + \ + init_wait_entry(&__wq_entry, 0); \ do { \ + int __wait; \ + \ KASSERT(!cold); \ \ + prepare_to_wait(&wqh, &__wq_entry, 0); \ + \ + __wait = !(condition); \ + \ mtx_leave(&(mtx)); \ - mtx_enter(&sch_mtx); \ - msleep(&wqh, &sch_mtx, 0, "drmweli", 0); \ - mtx_leave(&sch_mtx); \ + sleep_finish(0, __wait); \ mtx_enter(&(mtx)); \ } while (!(condition)); \ + finish_wait(&wqh, &__wq_entry); \ }) /* @@ -221,13 +234,12 @@ wake_up(wait_queue_head_t *wqh) wait_queue_entry_t *wqe; wait_queue_entry_t *tmp; mtx_enter(&wqh->lock); - + list_for_each_entry_safe(wqe, tmp, &wqh->head, entry) { KASSERT(wqe->func != NULL); if (wqe->func != NULL) wqe->func(wqe, 0, wqe->flags, NULL); } - wakeup(wqh); mtx_leave(&wqh->lock); } @@ -244,7 +256,6 @@ wake_up_all_locked(wait_queue_head_t *wqh) if (wqe->func != NULL) wqe->func(wqe, 0, wqe->flags, NULL); } - wakeup(wqh); } #define wake_up_interruptible(wqh) wake_up(wqh) @@ -255,31 +266,6 @@ wake_up_all_locked(wait_queue_head_t *wqh) .private = curproc, \ .func = autoremove_wake_function, \ .entry = LIST_HEAD_INIT((name).entry), \ - } - -static inline void -prepare_to_wait(wait_queue_head_t *wqh, wait_queue_entry_t *wqe, int state) -{ - if (wqe->flags == 0) { - mtx_enter(&sch_mtx); - wqe->flags = 1; } - MUTEX_ASSERT_LOCKED(&sch_mtx); - if (list_empty(&wqe->entry)) - __add_wait_queue(wqh, wqe); - sch_proc = curproc; - sch_ident = wqe; - sch_priority = state; -} - -static inline void -finish_wait(wait_queue_head_t *wqh, wait_queue_entry_t *wqe) -{ - MUTEX_ASSERT_LOCKED(&sch_mtx); - sch_ident = NULL; - if (!list_empty(&wqe->entry)) - list_del_init(&wqe->entry); - mtx_leave(&sch_mtx); -} #endif diff --git a/sys/dev/pci/drm/include/linux/ww_mutex.h b/sys/dev/pci/drm/include/linux/ww_mutex.h index d2b9b3834..d5b1ac263 100644 --- a/sys/dev/pci/drm/include/linux/ww_mutex.h +++ b/sys/dev/pci/drm/include/linux/ww_mutex.h @@ -209,7 +209,7 @@ static inline int ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) { return __ww_mutex_lock(lock, ctx, false, false); } - + static inline void ww_mutex_lock_slow(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) { (void)__ww_mutex_lock(lock, ctx, true, false); @@ -219,7 +219,7 @@ static inline int ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) { return __ww_mutex_lock(lock, ctx, false, true); } - + static inline int __must_check ww_mutex_lock_slow_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) { return __ww_mutex_lock(lock, ctx, true, true); diff --git a/sys/dev/pci/drm/include/uapi/drm/radeon_drm.h b/sys/dev/pci/drm/include/uapi/drm/radeon_drm.h index 490a59cc4..e38d07eb0 100644 --- a/sys/dev/pci/drm/include/uapi/drm/radeon_drm.h +++ b/sys/dev/pci/drm/include/uapi/drm/radeon_drm.h @@ -233,7 +233,7 @@ typedef union { # define R300_WAIT_3D 0x2 /* these two defines are DOING IT WRONG - however * we have userspace which relies on using these. - * The wait interface is backwards compat new + * The wait interface is backwards compat new * code should use the NEW_WAIT defines below * THESE ARE NOT BIT FIELDS */ diff --git a/sys/dev/pci/drm/linux_sort.c b/sys/dev/pci/drm/linux_sort.c index 402295335..e7497a4c7 100644 --- a/sys/dev/pci/drm/linux_sort.c +++ b/sys/dev/pci/drm/linux_sort.c @@ -56,7 +56,7 @@ static __inline void swapfunc(char *, char *, size_t, int); static __inline void swapfunc(char *a, char *b, size_t n, int swaptype) { - if (swaptype <= 1) + if (swaptype <= 1) swapcode(long, a, b, n) else swapcode(char, a, b, n) @@ -167,7 +167,7 @@ loop: SWAPINIT(a, es); void sort(void *a, size_t n, size_t es, int (*cmp)(const void *, const void *), - void *x) + void *x) { KASSERT(x == NULL); qsort(a, n, es, cmp); diff --git a/sys/dev/pci/drm/radeon/ObjectID.h b/sys/dev/pci/drm/radeon/ObjectID.h index 06192698b..bf5b73388 100644 --- a/sys/dev/pci/drm/radeon/ObjectID.h +++ b/sys/dev/pci/drm/radeon/ObjectID.h @@ -1,5 +1,5 @@ /* -* Copyright 2006-2007 Advanced Micro Devices, Inc. +* Copyright 2006-2007 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,13 +37,13 @@ #define GRAPH_OBJECT_TYPE_CONNECTOR 0x3 #define GRAPH_OBJECT_TYPE_ROUTER 0x4 /* deleted */ -#define GRAPH_OBJECT_TYPE_DISPLAY_PATH 0x6 +#define GRAPH_OBJECT_TYPE_DISPLAY_PATH 0x6 #define GRAPH_OBJECT_TYPE_GENERIC 0x7 /****************************************************/ /* Encoder Object ID Definition */ /****************************************************/ -#define ENCODER_OBJECT_ID_NONE 0x00 +#define ENCODER_OBJECT_ID_NONE 0x00 /* Radeon Class Display Hardware */ #define ENCODER_OBJECT_ID_INTERNAL_LVDS 0x01 @@ -96,7 +96,7 @@ /****************************************************/ /* Connector Object ID Definition */ /****************************************************/ -#define CONNECTOR_OBJECT_ID_NONE 0x00 +#define CONNECTOR_OBJECT_ID_NONE 0x00 #define CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I 0x01 #define CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I 0x02 #define CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D 0x03 @@ -156,7 +156,7 @@ #define RESERVED1_ID_MASK 0x0800 #define OBJECT_TYPE_MASK 0x7000 #define RESERVED2_ID_MASK 0x8000 - + #define OBJECT_ID_SHIFT 0x00 #define ENUM_ID_SHIFT 0x08 #define OBJECT_TYPE_SHIFT 0x0C @@ -177,14 +177,14 @@ /* Encoder Object ID definition - Shared with BIOS */ /****************************************************/ /* -#define ENCODER_INTERNAL_LVDS_ENUM_ID1 0x2101 +#define ENCODER_INTERNAL_LVDS_ENUM_ID1 0x2101 #define ENCODER_INTERNAL_TMDS1_ENUM_ID1 0x2102 #define ENCODER_INTERNAL_TMDS2_ENUM_ID1 0x2103 #define ENCODER_INTERNAL_DAC1_ENUM_ID1 0x2104 #define ENCODER_INTERNAL_DAC2_ENUM_ID1 0x2105 #define ENCODER_INTERNAL_SDVOA_ENUM_ID1 0x2106 #define ENCODER_INTERNAL_SDVOB_ENUM_ID1 0x2107 -#define ENCODER_SIL170B_ENUM_ID1 0x2108 +#define ENCODER_SIL170B_ENUM_ID1 0x2108 #define ENCODER_CH7303_ENUM_ID1 0x2109 #define ENCODER_CH7301_ENUM_ID1 0x210A #define ENCODER_INTERNAL_DVO1_ENUM_ID1 0x210B @@ -198,8 +198,8 @@ #define ENCODER_INTERNAL_KLDSCP_TMDS1_ENUM_ID1 0x2113 #define ENCODER_INTERNAL_KLDSCP_DVO1_ENUM_ID1 0x2114 #define ENCODER_INTERNAL_KLDSCP_DAC1_ENUM_ID1 0x2115 -#define ENCODER_INTERNAL_KLDSCP_DAC2_ENUM_ID1 0x2116 -#define ENCODER_SI178_ENUM_ID1 0x2117 +#define ENCODER_INTERNAL_KLDSCP_DAC2_ENUM_ID1 0x2116 +#define ENCODER_SI178_ENUM_ID1 0x2117 #define ENCODER_MVPU_FPGA_ENUM_ID1 0x2118 #define ENCODER_INTERNAL_DDI_ENUM_ID1 0x2119 #define ENCODER_VT1625_ENUM_ID1 0x211A @@ -314,7 +314,7 @@ #define ENCODER_SI178_ENUM_ID1 ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\ GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ - ENCODER_OBJECT_ID_SI178 << OBJECT_ID_SHIFT) + ENCODER_OBJECT_ID_SI178 << OBJECT_ID_SHIFT) #define ENCODER_MVPU_FPGA_ENUM_ID1 ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\ GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ @@ -322,7 +322,7 @@ #define ENCODER_INTERNAL_DDI_ENUM_ID1 ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\ GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ - ENCODER_OBJECT_ID_INTERNAL_DDI << OBJECT_ID_SHIFT) + ENCODER_OBJECT_ID_INTERNAL_DDI << OBJECT_ID_SHIFT) #define ENCODER_VT1625_ENUM_ID1 ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\ GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ @@ -350,7 +350,7 @@ #define ENCODER_INTERNAL_KLDSCP_LVTMA_ENUM_ID1 ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\ GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ - ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA << OBJECT_ID_SHIFT) + ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA << OBJECT_ID_SHIFT) #define ENCODER_INTERNAL_UNIPHY1_ENUM_ID1 ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\ GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ diff --git a/sys/dev/pci/drm/radeon/atombios.h b/sys/dev/pci/drm/radeon/atombios.h index da35a970f..f48283ced 100644 --- a/sys/dev/pci/drm/radeon/atombios.h +++ b/sys/dev/pci/drm/radeon/atombios.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 Advanced Micro Devices, Inc. + * Copyright 2006-2007 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,7 +21,7 @@ */ -/****************************************************************************/ +/****************************************************************************/ /*Portion I: Definitions shared between VBIOS and Driver */ /****************************************************************************/ @@ -42,7 +42,7 @@ #endif #ifdef _H2INC - #ifndef ULONG + #ifndef ULONG typedef unsigned long ULONG; #endif @@ -50,12 +50,12 @@ typedef unsigned char UCHAR; #endif - #ifndef USHORT + #ifndef USHORT typedef unsigned short USHORT; #endif #endif - -#define ATOM_DAC_A 0 + +#define ATOM_DAC_A 0 #define ATOM_DAC_B 1 #define ATOM_EXT_DAC 2 @@ -81,7 +81,7 @@ #define ATOM_EXT_CLOCK 10 #define ATOM_PPLL_INVALID 0xFF -#define ENCODER_REFCLK_SRC_P1PLL 0 +#define ENCODER_REFCLK_SRC_P1PLL 0 #define ENCODER_REFCLK_SRC_P2PLL 1 #define ENCODER_REFCLK_SRC_DCPLL 2 #define ENCODER_REFCLK_SRC_EXTCLK 3 @@ -90,10 +90,10 @@ #define ATOM_SCALER1 0 #define ATOM_SCALER2 1 -#define ATOM_SCALER_DISABLE 0 -#define ATOM_SCALER_CENTER 1 -#define ATOM_SCALER_EXPANSION 2 -#define ATOM_SCALER_MULTI_EX 3 +#define ATOM_SCALER_DISABLE 0 +#define ATOM_SCALER_CENTER 1 +#define ATOM_SCALER_EXPANSION 2 +#define ATOM_SCALER_MULTI_EX 3 #define ATOM_DISABLE 0 #define ATOM_ENABLE 1 @@ -137,7 +137,7 @@ #define ATOM_DAC2_CV ATOM_DAC1_CV #define ATOM_DAC2_NTSC ATOM_DAC1_NTSC #define ATOM_DAC2_PAL ATOM_DAC1_PAL - + #define ATOM_PM_ON 0 #define ATOM_PM_STANDBY 1 #define ATOM_PM_SUSPEND 2 @@ -173,7 +173,7 @@ #define ATOM_MAX_SIZE_OF_FIREGL_FLAG_STRING 3 //sizeof( ATOM_FIREGL_FLAG_STRING ) #define ATOM_FAKE_DESKTOP_STRING "DSK" //Flag used to enable mobile ASIC on Desktop -#define ATOM_MAX_SIZE_OF_FAKE_DESKTOP_STRING ATOM_MAX_SIZE_OF_FIREGL_FLAG_STRING +#define ATOM_MAX_SIZE_OF_FAKE_DESKTOP_STRING ATOM_MAX_SIZE_OF_FIREGL_FLAG_STRING #define ATOM_M54T_FLAG_STRING "M54T" //Flag used to enable M54T Support #define ATOM_MAX_SIZE_OF_M54T_FLAG_STRING 4 //sizeof( ATOM_M54T_FLAG_STRING ) @@ -194,7 +194,7 @@ #define OFFSET_TO_GET_ATOMBIOS_STRINGS_START 0x006e /* Common header for all ROM Data tables. - Every table pointed _ATOM_MASTER_DATA_TABLE has this common header. + Every table pointed _ATOM_MASTER_DATA_TABLE has this common header. And the pointer actually points to this header. */ typedef struct _ATOM_COMMON_TABLE_HEADER @@ -205,13 +205,13 @@ typedef struct _ATOM_COMMON_TABLE_HEADER /*Image can't be updated, while Driver needs to carry the new table! */ }ATOM_COMMON_TABLE_HEADER; -/****************************************************************************/ +/****************************************************************************/ // Structure stores the ROM header. -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_ROM_HEADER { ATOM_COMMON_TABLE_HEADER sHeader; - UCHAR uaFirmWareSignature[4]; /*Signature to distinguish between Atombios and non-atombios, + UCHAR uaFirmWareSignature[4]; /*Signature to distinguish between Atombios and non-atombios, atombios should init it as "ATOM", don't change the position */ USHORT usBiosRuntimeSegmentAddress; USHORT usProtectedModeInfoOffset; @@ -223,7 +223,7 @@ typedef struct _ATOM_ROM_HEADER USHORT usIoBaseAddress; USHORT usSubsystemVendorID; USHORT usSubsystemID; - USHORT usPCI_InfoOffset; + USHORT usPCI_InfoOffset; USHORT usMasterCommandTableOffset; /*Offset for SW to get all command table offsets, Don't change the position */ USHORT usMasterDataTableOffset; /*Offset for SW to get all data table offsets, Don't change the position */ UCHAR ucExtendedFunctionCode; @@ -237,9 +237,9 @@ typedef struct _ATOM_ROM_HEADER #define USHORT void* #endif -/****************************************************************************/ -// Structures used in Command.mtb -/****************************************************************************/ +/****************************************************************************/ +// Structures used in Command.mtb +/****************************************************************************/ typedef struct _ATOM_MASTER_LIST_OF_COMMAND_TABLES{ USHORT ASIC_Init; //Function Table, used by various SW components,latest version 1.1 USHORT GetDisplaySurfaceSize; //Atomic Table, Used by Bios when enabling HW ICON @@ -253,50 +253,50 @@ typedef struct _ATOM_MASTER_LIST_OF_COMMAND_TABLES{ USHORT GPIOPinControl; //Atomic Table, only used by Bios USHORT SetEngineClock; //Function Table,directly used by various SW components,latest version 1.1 USHORT SetMemoryClock; //Function Table,directly used by various SW components,latest version 1.1 - USHORT SetPixelClock; //Function Table,directly used by various SW components,latest version 1.2 + USHORT SetPixelClock; //Function Table,directly used by various SW components,latest version 1.2 USHORT EnableDispPowerGating; //Atomic Table, indirectly used by various SW components,called from ASIC_Init USHORT ResetMemoryDLL; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock USHORT ResetMemoryDevice; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock USHORT MemoryPLLInit; //Atomic Table, used only by Bios - USHORT AdjustDisplayPll; //Atomic Table, used by various SW componentes. - USHORT AdjustMemoryController; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock + USHORT AdjustDisplayPll; //Atomic Table, used by various SW componentes. + USHORT AdjustMemoryController; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock USHORT EnableASIC_StaticPwrMgt; //Atomic Table, only used by Bios - USHORT SetUniphyInstance; //Atomic Table, only used by Bios - USHORT DAC_LoadDetection; //Atomic Table, directly used by various SW components,latest version 1.2 + USHORT SetUniphyInstance; //Atomic Table, only used by Bios + USHORT DAC_LoadDetection; //Atomic Table, directly used by various SW components,latest version 1.2 USHORT LVTMAEncoderControl; //Atomic Table,directly used by various SW components,latest version 1.3 - USHORT HW_Misc_Operation; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT DAC1EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT DAC2EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT DVOOutputControl; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT CV1OutputControl; //Atomic Table, Atomic Table, Obsolete from Ry6xx, use DAC2 Output instead + USHORT HW_Misc_Operation; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT DAC1EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT DAC2EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT DVOOutputControl; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT CV1OutputControl; //Atomic Table, Atomic Table, Obsolete from Ry6xx, use DAC2 Output instead USHORT GetConditionalGoldenSetting; //Only used by Bios USHORT TVEncoderControl; //Function Table,directly used by various SW components,latest version 1.1 USHORT PatchMCSetting; //only used by BIOS USHORT MC_SEQ_Control; //only used by BIOS USHORT Gfx_Harvesting; //Atomic Table, Obsolete from Ry6xx, Now only used by BIOS for GFX harvesting USHORT EnableScaler; //Atomic Table, used only by Bios - USHORT BlankCRTC; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT EnableCRTC; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT GetPixelClock; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT BlankCRTC; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT EnableCRTC; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT GetPixelClock; //Atomic Table, directly used by various SW components,latest version 1.1 USHORT EnableVGA_Render; //Function Table,directly used by various SW components,latest version 1.1 USHORT GetSCLKOverMCLKRatio; //Atomic Table, only used by Bios USHORT SetCRTC_Timing; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT SetCRTC_OverScan; //Atomic Table, used by various SW components,latest version 1.1 + USHORT SetCRTC_OverScan; //Atomic Table, used by various SW components,latest version 1.1 USHORT SetCRTC_Replication; //Atomic Table, used only by Bios - USHORT SelectCRTC_Source; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT SelectCRTC_Source; //Atomic Table, directly used by various SW components,latest version 1.1 USHORT EnableGraphSurfaces; //Atomic Table, used only by Bios USHORT UpdateCRTC_DoubleBufferRegisters; //Atomic Table, used only by Bios USHORT LUT_AutoFill; //Atomic Table, only used by Bios USHORT EnableHW_IconCursor; //Atomic Table, only used by Bios - USHORT GetMemoryClock; //Atomic Table, directly used by various SW components,latest version 1.1 - USHORT GetEngineClock; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT GetMemoryClock; //Atomic Table, directly used by various SW components,latest version 1.1 + USHORT GetEngineClock; //Atomic Table, directly used by various SW components,latest version 1.1 USHORT SetCRTC_UsingDTDTiming; //Atomic Table, directly used by various SW components,latest version 1.1 USHORT ExternalEncoderControl; //Atomic Table, directly used by various SW components,latest version 2.1 USHORT LVTMAOutputControl; //Atomic Table, directly used by various SW components,latest version 1.1 USHORT VRAM_BlockDetectionByStrap; //Atomic Table, used only by Bios - USHORT MemoryCleanUp; //Atomic Table, only used by Bios + USHORT MemoryCleanUp; //Atomic Table, only used by Bios USHORT ProcessI2cChannelTransaction; //Function Table,only used by Bios - USHORT WriteOneByteToHWAssistedI2C; //Function Table,indirectly used by various SW components + USHORT WriteOneByteToHWAssistedI2C; //Function Table,indirectly used by various SW components USHORT ReadHWAssistedI2CStatus; //Atomic Table, indirectly used by various SW components USHORT SpeedFanControl; //Function Table,indirectly used by various SW components,called from ASIC_Init USHORT PowerConnectorDetection; //Atomic Table, directly used by various SW components,latest version 1.1 @@ -318,22 +318,22 @@ typedef struct _ATOM_MASTER_LIST_OF_COMMAND_TABLES{ USHORT DIG1EncoderControl; //Atomic Table,directly used by various SW components,latest version 1.1 USHORT DIG2EncoderControl; //Atomic Table,directly used by various SW components,latest version 1.1 USHORT DIG1TransmitterControl; //Atomic Table,directly used by various SW components,latest version 1.1 - USHORT DIG2TransmitterControl; //Atomic Table,directly used by various SW components,latest version 1.1 + USHORT DIG2TransmitterControl; //Atomic Table,directly used by various SW components,latest version 1.1 USHORT ProcessAuxChannelTransaction; //Function Table,only used by Bios USHORT DPEncoderService; //Function Table,only used by Bios USHORT GetVoltageInfo; //Function Table,only used by Bios since SI -}ATOM_MASTER_LIST_OF_COMMAND_TABLES; +}ATOM_MASTER_LIST_OF_COMMAND_TABLES; -// For backward compatible +// For backward compatible #define ReadEDIDFromHWAssistedI2C ProcessI2cChannelTransaction #define DPTranslatorControl DIG2EncoderControl #define UNIPHYTransmitterControl DIG1TransmitterControl #define LVTMATransmitterControl DIG2TransmitterControl #define SetCRTC_DPM_State GetConditionalGoldenSetting -#define ASIC_StaticPwrMgtStatusChange SetUniphyInstance +#define ASIC_StaticPwrMgtStatusChange SetUniphyInstance #define HPDInterruptService ReadHWAssistedI2CStatus #define EnableVGA_Access GetSCLKOverMCLKRatio -#define EnableYUV GetDispObjectInfo +#define EnableYUV GetDispObjectInfo #define DynamicClockGating EnableDispPowerGating #define SetupHWAssistedI2CStatus ComputeMemoryClockParam @@ -348,18 +348,18 @@ typedef struct _ATOM_MASTER_COMMAND_TABLE ATOM_MASTER_LIST_OF_COMMAND_TABLES ListOfCommandTables; }ATOM_MASTER_COMMAND_TABLE; -/****************************************************************************/ +/****************************************************************************/ // Structures used in every command table -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_TABLE_ATTRIBUTE { #if ATOM_BIG_ENDIAN USHORT UpdatedByUtility:1; //[15]=Table updated by utility flag - USHORT PS_SizeInBytes:7; //[14:8]=Size of parameter space in Bytes (multiple of a dword), - USHORT WS_SizeInBytes:8; //[7:0]=Size of workspace in Bytes (in multiple of a dword), + USHORT PS_SizeInBytes:7; //[14:8]=Size of parameter space in Bytes (multiple of a dword), + USHORT WS_SizeInBytes:8; //[7:0]=Size of workspace in Bytes (in multiple of a dword), #else - USHORT WS_SizeInBytes:8; //[7:0]=Size of workspace in Bytes (in multiple of a dword), - USHORT PS_SizeInBytes:7; //[14:8]=Size of parameter space in Bytes (multiple of a dword), + USHORT WS_SizeInBytes:8; //[7:0]=Size of workspace in Bytes (in multiple of a dword), + USHORT PS_SizeInBytes:7; //[14:8]=Size of parameter space in Bytes (multiple of a dword), USHORT UpdatedByUtility:1; //[15]=Table updated by utility flag #endif }ATOM_TABLE_ATTRIBUTE; @@ -370,37 +370,37 @@ typedef union _ATOM_TABLE_ATTRIBUTE_ACCESS USHORT susAccess; }ATOM_TABLE_ATTRIBUTE_ACCESS; -/****************************************************************************/ +/****************************************************************************/ // Common header for all command tables. -// Every table pointed by _ATOM_MASTER_COMMAND_TABLE has this common header. +// Every table pointed by _ATOM_MASTER_COMMAND_TABLE has this common header. // And the pointer actually points to this header. -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_COMMON_ROM_COMMAND_TABLE_HEADER { ATOM_COMMON_TABLE_HEADER CommonHeader; - ATOM_TABLE_ATTRIBUTE TableAttribute; + ATOM_TABLE_ATTRIBUTE TableAttribute; }ATOM_COMMON_ROM_COMMAND_TABLE_HEADER; -/****************************************************************************/ +/****************************************************************************/ // Structures used by ComputeMemoryEnginePLLTable -/****************************************************************************/ +/****************************************************************************/ #define COMPUTE_MEMORY_PLL_PARAM 1 #define COMPUTE_ENGINE_PLL_PARAM 2 #define ADJUST_MC_SETTING_PARAM 3 -/****************************************************************************/ +/****************************************************************************/ // Structures used by AdjustMemoryControllerTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_ADJUST_MEMORY_CLOCK_FREQ { #if ATOM_BIG_ENDIAN - ULONG ulPointerReturnFlag:1; // BYTE_3[7]=1 - Return the pointer to the right Data Block; BYTE_3[7]=0 - Program the right Data Block + ULONG ulPointerReturnFlag:1; // BYTE_3[7]=1 - Return the pointer to the right Data Block; BYTE_3[7]=0 - Program the right Data Block ULONG ulMemoryModuleNumber:7; // BYTE_3[6:0] ULONG ulClockFreq:24; #else ULONG ulClockFreq:24; ULONG ulMemoryModuleNumber:7; // BYTE_3[6:0] - ULONG ulPointerReturnFlag:1; // BYTE_3[7]=1 - Return the pointer to the right Data Block; BYTE_3[7]=0 - Program the right Data Block + ULONG ulPointerReturnFlag:1; // BYTE_3[7]=1 - Return the pointer to the right Data Block; BYTE_3[7]=0 - Program the right Data Block #endif }ATOM_ADJUST_MEMORY_CLOCK_FREQ; #define POINTER_RETURN_FLAG 0x80 @@ -408,7 +408,7 @@ typedef struct _ATOM_ADJUST_MEMORY_CLOCK_FREQ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS { ULONG ulClock; //When returen, it's the re-calculated clock based on given Fb_div Post_Div and ref_div - UCHAR ucAction; //0:reserved //1:Memory //2:Engine + UCHAR ucAction; //0:reserved //1:Memory //2:Engine UCHAR ucReserved; //may expand to return larger Fbdiv later UCHAR ucFbDiv; //return value UCHAR ucPostDiv; //return value @@ -416,7 +416,7 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V2 { - ULONG ulClock; //When return, [23:0] return real clock + ULONG ulClock; //When return, [23:0] return real clock UCHAR ucAction; //0:reserved;COMPUTE_MEMORY_PLL_PARAM:Memory;COMPUTE_ENGINE_PLL_PARAM:Engine. it return ref_div to be written to register USHORT usFbDiv; //return Feedback value to be written to register UCHAR ucPostDiv; //return post div to be written to register @@ -451,8 +451,8 @@ typedef struct _ATOM_COMPUTE_CLOCK_FREQ typedef struct _ATOM_S_MPLL_FB_DIVIDER { - USHORT usFbDivFrac; - USHORT usFbDiv; + USHORT usFbDivFrac; + USHORT usFbDiv; }ATOM_S_MPLL_FB_DIVIDER; typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V3 @@ -463,9 +463,9 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V3 ULONG ulClockParams; //ULONG access for BE ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter }; - UCHAR ucRefDiv; //Output Parameter - UCHAR ucPostDiv; //Output Parameter - UCHAR ucCntlFlag; //Output Parameter + UCHAR ucRefDiv; //Output Parameter + UCHAR ucPostDiv; //Output Parameter + UCHAR ucCntlFlag; //Output Parameter UCHAR ucReserved; }COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V3; @@ -481,9 +481,9 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V4 { #if ATOM_BIG_ENDIAN ULONG ucPostDiv:8; //return parameter: post divider which is used to program to register directly - ULONG ulClock:24; //Input= target clock, output = actual clock + ULONG ulClock:24; //Input= target clock, output = actual clock #else - ULONG ulClock:24; //Input= target clock, output = actual clock + ULONG ulClock:24; //Input= target clock, output = actual clock ULONG ucPostDiv:8; //return parameter: post divider which is used to program to register directly #endif }COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V4; @@ -496,14 +496,14 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V5 ULONG ulClockParams; //ULONG access for BE ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter }; - UCHAR ucRefDiv; //Output Parameter - UCHAR ucPostDiv; //Output Parameter + UCHAR ucRefDiv; //Output Parameter + UCHAR ucPostDiv; //Output Parameter union { UCHAR ucCntlFlag; //Output Flags UCHAR ucInputFlag; //Input Flags. ucInputFlag[0] - Strobe(1)/Performance(0) mode }; - UCHAR ucReserved; + UCHAR ucReserved; }COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V5; @@ -522,14 +522,14 @@ typedef struct _COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_6 { COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V4 ulClock; //Output Parameter: ucPostDiv=DFS divider ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter: PLL FB divider - UCHAR ucPllRefDiv; //Output Parameter: PLL ref divider - UCHAR ucPllPostDiv; //Output Parameter: PLL post divider + UCHAR ucPllRefDiv; //Output Parameter: PLL ref divider + UCHAR ucPllPostDiv; //Output Parameter: PLL post divider UCHAR ucPllCntlFlag; //Output Flags: control flag - UCHAR ucReserved; + UCHAR ucReserved; }COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_6; //ucPllCntlFlag -#define SPLL_CNTL_FLAG_VCO_MODE_MASK 0x03 +#define SPLL_CNTL_FLAG_VCO_MODE_MASK 0x03 // ucInputFlag @@ -540,22 +540,22 @@ typedef struct _COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_1 { union { - ULONG ulClock; + ULONG ulClock; ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output:UPPER_WORD=FB_DIV_INTEGER, LOWER_WORD=FB_DIV_FRAC shl (16-FB_FRACTION_BITS) }; - UCHAR ucDllSpeed; //Output + UCHAR ucDllSpeed; //Output UCHAR ucPostDiv; //Output union{ UCHAR ucInputFlag; //Input : ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN: 1-StrobeMode, 0-PerformanceMode - UCHAR ucPllCntlFlag; //Output: + UCHAR ucPllCntlFlag; //Output: }; - UCHAR ucBWCntl; + UCHAR ucBWCntl; }COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_1; // definition of ucInputFlag #define MPLL_INPUT_FLAG_STROBE_MODE_EN 0x01 // definition of ucPllCntlFlag -#define MPLL_CNTL_FLAG_VCO_MODE_MASK 0x03 +#define MPLL_CNTL_FLAG_VCO_MODE_MASK 0x03 #define MPLL_CNTL_FLAG_BYPASS_DQ_PLL 0x04 #define MPLL_CNTL_FLAG_QDR_ENABLE 0x08 #define MPLL_CNTL_FLAG_AD_HALF_RATE 0x10 @@ -576,9 +576,9 @@ typedef struct _DYNAMICE_ENGINE_SETTINGS_PARAMETER ULONG ulReserved; }DYNAMICE_ENGINE_SETTINGS_PARAMETER; -/****************************************************************************/ +/****************************************************************************/ // Structures used by SetEngineClockTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _SET_ENGINE_CLOCK_PARAMETERS { ULONG ulTargetEngineClock; //In 10Khz unit @@ -590,9 +590,9 @@ typedef struct _SET_ENGINE_CLOCK_PS_ALLOCATION COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_PS_ALLOCATION sReserved; }SET_ENGINE_CLOCK_PS_ALLOCATION; -/****************************************************************************/ +/****************************************************************************/ // Structures used by SetMemoryClockTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _SET_MEMORY_CLOCK_PARAMETERS { ULONG ulTargetMemoryClock; //In 10Khz unit @@ -604,9 +604,9 @@ typedef struct _SET_MEMORY_CLOCK_PS_ALLOCATION COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_PS_ALLOCATION sReserved; }SET_MEMORY_CLOCK_PS_ALLOCATION; -/****************************************************************************/ +/****************************************************************************/ // Structures used by ASIC_Init.ctb -/****************************************************************************/ +/****************************************************************************/ typedef struct _ASIC_INIT_PARAMETERS { ULONG ulDefaultEngineClock; //In 10Khz unit @@ -619,29 +619,29 @@ typedef struct _ASIC_INIT_PS_ALLOCATION SET_ENGINE_CLOCK_PS_ALLOCATION sReserved; //Caller doesn't need to init this structure }ASIC_INIT_PS_ALLOCATION; -/****************************************************************************/ +/****************************************************************************/ // Structure used by DynamicClockGatingTable.ctb -/****************************************************************************/ -typedef struct _DYNAMIC_CLOCK_GATING_PARAMETERS +/****************************************************************************/ +typedef struct _DYNAMIC_CLOCK_GATING_PARAMETERS { UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE UCHAR ucPadding[3]; }DYNAMIC_CLOCK_GATING_PARAMETERS; #define DYNAMIC_CLOCK_GATING_PS_ALLOCATION DYNAMIC_CLOCK_GATING_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structure used by EnableDispPowerGatingTable.ctb -/****************************************************************************/ -typedef struct _ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1 +/****************************************************************************/ +typedef struct _ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1 { UCHAR ucDispPipeId; // ATOM_CRTC1, ATOM_CRTC2, ... UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE UCHAR ucPadding[2]; }ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1; -/****************************************************************************/ +/****************************************************************************/ // Structure used by EnableASIC_StaticPwrMgtTable.ctb -/****************************************************************************/ +/****************************************************************************/ typedef struct _ENABLE_ASIC_STATIC_PWR_MGT_PARAMETERS { UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE @@ -649,9 +649,9 @@ typedef struct _ENABLE_ASIC_STATIC_PWR_MGT_PARAMETERS }ENABLE_ASIC_STATIC_PWR_MGT_PARAMETERS; #define ENABLE_ASIC_STATIC_PWR_MGT_PS_ALLOCATION ENABLE_ASIC_STATIC_PWR_MGT_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by DAC_LoadDetectionTable.ctb -/****************************************************************************/ +/****************************************************************************/ typedef struct _DAC_LOAD_DETECTION_PARAMETERS { USHORT usDeviceID; //{ATOM_DEVICE_CRTx_SUPPORT,ATOM_DEVICE_TVx_SUPPORT,ATOM_DEVICE_CVx_SUPPORT} @@ -668,10 +668,10 @@ typedef struct _DAC_LOAD_DETECTION_PS_ALLOCATION ULONG Reserved[2];// Don't set this one, allocation for EXT DAC }DAC_LOAD_DETECTION_PS_ALLOCATION; -/****************************************************************************/ +/****************************************************************************/ // Structures used by DAC1EncoderControlTable.ctb and DAC2EncoderControlTable.ctb -/****************************************************************************/ -typedef struct _DAC_ENCODER_CONTROL_PARAMETERS +/****************************************************************************/ +typedef struct _DAC_ENCODER_CONTROL_PARAMETERS { USHORT usPixelClock; // in 10KHz; for bios convenient UCHAR ucDacStandard; // See definition of ATOM_DACx_xxx, For DEC3.0, bit 7 used as internal flag to indicate DAC2 (==1) or DAC1 (==0) @@ -682,28 +682,28 @@ typedef struct _DAC_ENCODER_CONTROL_PARAMETERS #define DAC_ENCODER_CONTROL_PS_ALLOCATION DAC_ENCODER_CONTROL_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by DIG1EncoderControlTable // DIG2EncoderControlTable // ExternalEncoderControlTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _DIG_ENCODER_CONTROL_PARAMETERS { USHORT usPixelClock; // in 10KHz; for bios convenient - UCHAR ucConfig; + UCHAR ucConfig; // [2] Link Select: // =0: PHY linkA if bfLane<3 // =1: PHY linkB if bfLanes<3 // =0: PHY linkA+B if bfLanes=3 // [3] Transmitter Sel // =0: UNIPHY or PCIEPHY - // =1: LVTMA - UCHAR ucAction; // =0: turn off encoder - // =1: turn on encoder + // =1: LVTMA + UCHAR ucAction; // =0: turn off encoder + // =1: turn on encoder UCHAR ucEncoderMode; - // =0: DP encoder - // =1: LVDS encoder - // =2: DVI encoder + // =0: DP encoder + // =1: LVDS encoder + // =2: DVI encoder // =3: HDMI encoder // =4: SDVO encoder UCHAR ucLaneNum; // how many lanes to enable @@ -768,11 +768,11 @@ typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V2 { USHORT usPixelClock; // in 10KHz; for bios convenient ATOM_DIG_ENCODER_CONFIG_V2 acConfig; - UCHAR ucAction; + UCHAR ucAction; UCHAR ucEncoderMode; - // =0: DP encoder - // =1: LVDS encoder - // =2: DVI encoder + // =0: DP encoder + // =1: LVDS encoder + // =2: DVI encoder // =3: HDMI encoder // =4: SDVO encoder UCHAR ucLaneNum; // how many lanes to enable @@ -843,12 +843,12 @@ typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V3 { USHORT usPixelClock; // in 10KHz; for bios convenient ATOM_DIG_ENCODER_CONFIG_V3 acConfig; - UCHAR ucAction; + UCHAR ucAction; union { UCHAR ucEncoderMode; - // =0: DP encoder - // =1: LVDS encoder - // =2: DVI encoder + // =0: DP encoder + // =1: LVDS encoder + // =2: DVI encoder // =3: HDMI encoder // =4: SDVO encoder // =5: DP audio @@ -864,7 +864,7 @@ typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V3 //ucTableFormatRevision=1 //ucTableContentRevision=4 -// start from NI +// start from NI // Following function ENABLE sub-function will be used by driver when TMDS/HDMI/LVDS is used, disable function will be used by driver typedef struct _ATOM_DIG_ENCODER_CONFIG_V4 { @@ -902,12 +902,12 @@ typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V4 ATOM_DIG_ENCODER_CONFIG_V4 acConfig; UCHAR ucConfig; }; - UCHAR ucAction; + UCHAR ucAction; union { UCHAR ucEncoderMode; - // =0: DP encoder - // =1: LVDS encoder - // =2: DVI encoder + // =0: DP encoder + // =1: LVDS encoder + // =2: DVI encoder // =3: HDMI encoder // =4: SDVO encoder // =5: DP audio @@ -921,9 +921,9 @@ typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V4 UCHAR ucHPD_ID; // HPD ID (1-6). =0 means to skip HDP programming. New comparing to previous version }DIG_ENCODER_CONTROL_PARAMETERS_V4; -// define ucBitPerColor: +// define ucBitPerColor: #define PANEL_BPC_UNDEFINE 0x00 -#define PANEL_6BIT_PER_COLOR 0x01 +#define PANEL_6BIT_PER_COLOR 0x01 #define PANEL_8BIT_PER_COLOR 0x02 #define PANEL_10BIT_PER_COLOR 0x03 #define PANEL_12BIT_PER_COLOR 0x04 @@ -934,11 +934,11 @@ typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V4 #define DP_PANEL_MODE_INTERNAL_DP2_MODE 0x01 #define DP_PANEL_MODE_INTERNAL_DP1_MODE 0x11 -/****************************************************************************/ +/****************************************************************************/ // Structures used by UNIPHYTransmitterControlTable // LVTMATransmitterControlTable // DVOOutputControlTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_DP_VS_MODE { UCHAR ucLaneSel; @@ -954,36 +954,36 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS ATOM_DP_VS_MODE asMode; // DP Voltage swing mode }; UCHAR ucConfig; - // [0]=0: 4 lane Link, - // =1: 8 lane Link ( Dual Links TMDS ) - // [1]=0: InCoherent mode - // =1: Coherent Mode + // [0]=0: 4 lane Link, + // =1: 8 lane Link ( Dual Links TMDS ) + // [1]=0: InCoherent mode + // =1: Coherent Mode // [2] Link Select: // =0: PHY linkA if bfLane<3 // =1: PHY linkB if bfLanes<3 - // =0: PHY linkA+B if bfLanes=3 + // =0: PHY linkA+B if bfLanes=3 // [5:4]PCIE lane Sel // =0: lane 0~3 or 0~7 // =1: lane 4~7 // =2: lane 8~11 or 8~15 - // =3: lane 12~15 - UCHAR ucAction; // =0: turn off encoder - // =1: turn on encoder + // =3: lane 12~15 + UCHAR ucAction; // =0: turn off encoder + // =1: turn on encoder UCHAR ucReserved[4]; }DIG_TRANSMITTER_CONTROL_PARAMETERS; -#define DIG_TRANSMITTER_CONTROL_PS_ALLOCATION DIG_TRANSMITTER_CONTROL_PARAMETERS +#define DIG_TRANSMITTER_CONTROL_PS_ALLOCATION DIG_TRANSMITTER_CONTROL_PARAMETERS //ucInitInfo -#define ATOM_TRAMITTER_INITINFO_CONNECTOR_MASK 0x00ff +#define ATOM_TRAMITTER_INITINFO_CONNECTOR_MASK 0x00ff -//ucConfig +//ucConfig #define ATOM_TRANSMITTER_CONFIG_8LANE_LINK 0x01 #define ATOM_TRANSMITTER_CONFIG_COHERENT 0x02 #define ATOM_TRANSMITTER_CONFIG_LINK_SEL_MASK 0x04 #define ATOM_TRANSMITTER_CONFIG_LINKA 0x00 #define ATOM_TRANSMITTER_CONFIG_LINKB 0x04 -#define ATOM_TRANSMITTER_CONFIG_LINKA_B 0x00 +#define ATOM_TRANSMITTER_CONFIG_LINKA_B 0x00 #define ATOM_TRANSMITTER_CONFIG_LINKB_A 0x04 #define ATOM_TRANSMITTER_CONFIG_ENCODER_SEL_MASK 0x08 // only used when ATOM_TRANSMITTER_ACTION_ENABLE @@ -1025,7 +1025,7 @@ typedef struct _ATOM_DIG_TRANSMITTER_CONFIG_V2 UCHAR ucTransmitterSel:2; //bit7:6: =0 Dig Transmitter 1 ( Uniphy AB ) // =1 Dig Transmitter 2 ( Uniphy CD ) // =2 Dig Transmitter 3 ( Uniphy EF ) - UCHAR ucReserved:1; + UCHAR ucReserved:1; UCHAR fDPConnector:1; //bit4=0: DP connector =1: None DP connector UCHAR ucEncoderSel:1; //bit3=0: Data/Clk path source from DIGA( DIG inst0 ). =1: Data/clk path source from DIGB ( DIG inst1 ) UCHAR ucLinkSel:1; //bit2=0: Uniphy LINKA or C or E when fDualLinkConnector=0. when fDualLinkConnector=1, it means master link of dual link is A or C or E @@ -1040,14 +1040,14 @@ typedef struct _ATOM_DIG_TRANSMITTER_CONFIG_V2 // =1: Uniphy LINKB or D or F when fDualLinkConnector=0. when fDualLinkConnector=1, it means master link of dual link is B or D or F UCHAR ucEncoderSel:1; //bit3=0: Data/Clk path source from DIGA( DIG inst0 ). =1: Data/clk path source from DIGB ( DIG inst1 ) UCHAR fDPConnector:1; //bit4=0: DP connector =1: None DP connector - UCHAR ucReserved:1; + UCHAR ucReserved:1; UCHAR ucTransmitterSel:2; //bit7:6: =0 Dig Transmitter 1 ( Uniphy AB ) // =1 Dig Transmitter 2 ( Uniphy CD ) // =2 Dig Transmitter 3 ( Uniphy EF ) #endif }ATOM_DIG_TRANSMITTER_CONFIG_V2; -//ucConfig +//ucConfig //Bit0 #define ATOM_TRANSMITTER_CONFIG_V2_DUAL_LINK_CONNECTOR 0x01 @@ -1126,7 +1126,7 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V3 UCHAR ucReserved[3]; }DIG_TRANSMITTER_CONTROL_PARAMETERS_V3; -//ucConfig +//ucConfig //Bit0 #define ATOM_TRANSMITTER_CONFIG_V3_DUAL_LINK_CONNECTOR 0x01 @@ -1156,17 +1156,17 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V3 #define ATOM_TRANSMITTER_CONFIG_V3_TRANSMITTER3 0x80 //EF -/****************************************************************************/ +/****************************************************************************/ // Structures used by UNIPHYTransmitterControlTable V1.4 // ASIC Families: NI // ucTableFormatRevision=1 // ucTableContentRevision=4 -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_DP_VS_MODE_V4 { UCHAR ucLaneSel; union - { + { UCHAR ucLaneSet; struct { #if ATOM_BIG_ENDIAN @@ -1179,9 +1179,9 @@ typedef struct _ATOM_DP_VS_MODE_V4 UCHAR ucPOST_CURSOR2:2; //Bit[7:6] Post Cursor2 Level <= New in V4 #endif }; - }; + }; }ATOM_DP_VS_MODE_V4; - + typedef struct _ATOM_DIG_TRANSMITTER_CONFIG_V4 { #if ATOM_BIG_ENDIAN @@ -1220,24 +1220,24 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V4 ATOM_DIG_TRANSMITTER_CONFIG_V4 acConfig; UCHAR ucConfig; }; - UCHAR ucAction; // define as ATOM_TRANSMITER_ACTION_XXX + UCHAR ucAction; // define as ATOM_TRANSMITER_ACTION_XXX UCHAR ucLaneNum; UCHAR ucReserved[3]; }DIG_TRANSMITTER_CONTROL_PARAMETERS_V4; -//ucConfig +//ucConfig //Bit0 #define ATOM_TRANSMITTER_CONFIG_V4_DUAL_LINK_CONNECTOR 0x01 //Bit1 #define ATOM_TRANSMITTER_CONFIG_V4_COHERENT 0x02 //Bit2 #define ATOM_TRANSMITTER_CONFIG_V4_LINK_SEL_MASK 0x04 -#define ATOM_TRANSMITTER_CONFIG_V4_LINKA 0x00 +#define ATOM_TRANSMITTER_CONFIG_V4_LINKA 0x00 #define ATOM_TRANSMITTER_CONFIG_V4_LINKB 0x04 // Bit3 #define ATOM_TRANSMITTER_CONFIG_V4_ENCODER_SEL_MASK 0x08 -#define ATOM_TRANSMITTER_CONFIG_V4_DIG1_ENCODER 0x00 -#define ATOM_TRANSMITTER_CONFIG_V4_DIG2_ENCODER 0x08 +#define ATOM_TRANSMITTER_CONFIG_V4_DIG1_ENCODER 0x00 +#define ATOM_TRANSMITTER_CONFIG_V4_DIG2_ENCODER 0x08 // Bit5:4 #define ATOM_TRANSMITTER_CONFIG_V4_REFCLK_SEL_MASK 0x30 #define ATOM_TRANSMITTER_CONFIG_V4_P1PLL 0x00 @@ -1256,13 +1256,13 @@ typedef struct _ATOM_DIG_TRANSMITTER_CONFIG_V5 #if ATOM_BIG_ENDIAN UCHAR ucReservd1:1; UCHAR ucHPDSel:3; - UCHAR ucPhyClkSrcId:2; - UCHAR ucCoherentMode:1; + UCHAR ucPhyClkSrcId:2; + UCHAR ucCoherentMode:1; UCHAR ucReserved:1; #else UCHAR ucReserved:1; - UCHAR ucCoherentMode:1; - UCHAR ucPhyClkSrcId:2; + UCHAR ucCoherentMode:1; + UCHAR ucPhyClkSrcId:2; UCHAR ucHPDSel:3; UCHAR ucReservd1:1; #endif @@ -1280,14 +1280,14 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5 ATOM_DIG_TRANSMITTER_CONFIG_V5 asConfig; UCHAR ucConfig; }; - UCHAR ucDigEncoderSel; // indicate DIG front end encoder + UCHAR ucDigEncoderSel; // indicate DIG front end encoder UCHAR ucDPLaneSet; UCHAR ucReserved; UCHAR ucReserved1; }DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5; //ucPhyId -#define ATOM_PHY_ID_UNIPHYA 0 +#define ATOM_PHY_ID_UNIPHYA 0 #define ATOM_PHY_ID_UNIPHYB 1 #define ATOM_PHY_ID_UNIPHYC 2 #define ATOM_PHY_ID_UNIPHYD 3 @@ -1317,12 +1317,12 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5 #define DP_LANE_SET__0DB_0_6V 0x01 #define DP_LANE_SET__0DB_0_8V 0x02 #define DP_LANE_SET__0DB_1_2V 0x03 -#define DP_LANE_SET__3_5DB_0_4V 0x08 +#define DP_LANE_SET__3_5DB_0_4V 0x08 #define DP_LANE_SET__3_5DB_0_6V 0x09 #define DP_LANE_SET__3_5DB_0_8V 0x0a #define DP_LANE_SET__6DB_0_4V 0x10 #define DP_LANE_SET__6DB_0_6V 0x11 -#define DP_LANE_SET__9_5DB_0_4V 0x18 +#define DP_LANE_SET__9_5DB_0_4V 0x18 // ATOM_DIG_TRANSMITTER_CONFIG_V5 asConfig; // Bit1 @@ -1334,7 +1334,7 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5 #define ATOM_TRANSMITTER_CONFIG_V5_P1PLL 0x00 #define ATOM_TRANSMITTER_CONFIG_V5_P2PLL 0x04 -#define ATOM_TRANSMITTER_CONFIG_V5_P0PLL 0x08 +#define ATOM_TRANSMITTER_CONFIG_V5_P0PLL 0x08 #define ATOM_TRANSMITTER_CONFIG_V5_REFCLK_SRC_EXT 0x0c // Bit6:4 #define ATOM_TRANSMITTER_CONFIG_V5_HPD_SEL_MASK 0x70 @@ -1351,25 +1351,25 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5 #define DIG_TRANSMITTER_CONTROL_PS_ALLOCATION_V1_5 DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5 -/****************************************************************************/ +/****************************************************************************/ // Structures used by ExternalEncoderControlTable V1.3 // ASIC Families: Evergreen, Llano, NI // ucTableFormatRevision=1 // ucTableContentRevision=3 -/****************************************************************************/ +/****************************************************************************/ typedef struct _EXTERNAL_ENCODER_CONTROL_PARAMETERS_V3 { union{ - USHORT usPixelClock; // pixel clock in 10Khz, valid when ucAction=SETUP/ENABLE_OUTPUT + USHORT usPixelClock; // pixel clock in 10Khz, valid when ucAction=SETUP/ENABLE_OUTPUT USHORT usConnectorId; // connector id, valid when ucAction = INIT }; - UCHAR ucConfig; // indicate which encoder, and DP link rate when ucAction = SETUP/ENABLE_OUTPUT - UCHAR ucAction; // + UCHAR ucConfig; // indicate which encoder, and DP link rate when ucAction = SETUP/ENABLE_OUTPUT + UCHAR ucAction; // UCHAR ucEncoderMode; // encoder mode, only used when ucAction = SETUP/ENABLE_OUTPUT - UCHAR ucLaneNum; // lane number, only used when ucAction = SETUP/ENABLE_OUTPUT + UCHAR ucLaneNum; // lane number, only used when ucAction = SETUP/ENABLE_OUTPUT UCHAR ucBitPerColor; // output bit per color, only valid when ucAction = SETUP/ENABLE_OUTPUT and ucEncodeMode= DP - UCHAR ucReserved; + UCHAR ucReserved; }EXTERNAL_ENCODER_CONTROL_PARAMETERS_V3; // ucAction @@ -1399,29 +1399,29 @@ typedef struct _EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION_V3 }EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION_V3; -/****************************************************************************/ +/****************************************************************************/ // Structures used by DAC1OuputControlTable // DAC2OuputControlTable // LVTMAOutputControlTable (Before DEC30) // TMDSAOutputControlTable (Before DEC30) -/****************************************************************************/ +/****************************************************************************/ typedef struct _DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS { UCHAR ucAction; // Possible input:ATOM_ENABLE||ATOMDISABLE // When the display is LCD, in addition to above: // ATOM_LCD_BLOFF|| ATOM_LCD_BLON ||ATOM_LCD_BL_BRIGHTNESS_CONTROL||ATOM_LCD_SELFTEST_START|| // ATOM_LCD_SELFTEST_STOP - + UCHAR aucPadding[3]; // padding to DWORD aligned }DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS; #define DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS -#define CRT1_OUTPUT_CONTROL_PARAMETERS DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS +#define CRT1_OUTPUT_CONTROL_PARAMETERS DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS #define CRT1_OUTPUT_CONTROL_PS_ALLOCATION DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION -#define CRT2_OUTPUT_CONTROL_PARAMETERS DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS +#define CRT2_OUTPUT_CONTROL_PARAMETERS DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS #define CRT2_OUTPUT_CONTROL_PS_ALLOCATION DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION #define CV1_OUTPUT_CONTROL_PARAMETERS DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS @@ -1443,9 +1443,9 @@ typedef struct _DISPLAY_DEVICE_OUTPUT_CONTROL_PARAMETERS #define DVO_OUTPUT_CONTROL_PS_ALLOCATION DIG_TRANSMITTER_CONTROL_PS_ALLOCATION #define DVO_OUTPUT_CONTROL_PARAMETERS_V3 DIG_TRANSMITTER_CONTROL_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by BlankCRTCTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _BLANK_CRTC_PARAMETERS { UCHAR ucCRTC; // ATOM_CRTC1 or ATOM_CRTC2 @@ -1456,22 +1456,22 @@ typedef struct _BLANK_CRTC_PARAMETERS }BLANK_CRTC_PARAMETERS; #define BLANK_CRTC_PS_ALLOCATION BLANK_CRTC_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by EnableCRTCTable // EnableCRTCMemReqTable // UpdateCRTC_DoubleBufferRegistersTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ENABLE_CRTC_PARAMETERS { UCHAR ucCRTC; // ATOM_CRTC1 or ATOM_CRTC2 - UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE + UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE UCHAR ucPadding[2]; }ENABLE_CRTC_PARAMETERS; #define ENABLE_CRTC_PS_ALLOCATION ENABLE_CRTC_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by SetCRTC_OverScanTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _SET_CRTC_OVERSCAN_PARAMETERS { USHORT usOverscanRight; // right @@ -1483,9 +1483,9 @@ typedef struct _SET_CRTC_OVERSCAN_PARAMETERS }SET_CRTC_OVERSCAN_PARAMETERS; #define SET_CRTC_OVERSCAN_PS_ALLOCATION SET_CRTC_OVERSCAN_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by SetCRTC_ReplicationTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _SET_CRTC_REPLICATION_PARAMETERS { UCHAR ucH_Replication; // horizontal replication @@ -1495,9 +1495,9 @@ typedef struct _SET_CRTC_REPLICATION_PARAMETERS }SET_CRTC_REPLICATION_PARAMETERS; #define SET_CRTC_REPLICATION_PS_ALLOCATION SET_CRTC_REPLICATION_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by SelectCRTC_SourceTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _SELECT_CRTC_SOURCE_PARAMETERS { UCHAR ucCRTC; // ATOM_CRTC1 or ATOM_CRTC2 @@ -1515,7 +1515,7 @@ typedef struct _SELECT_CRTC_SOURCE_PARAMETERS_V2 }SELECT_CRTC_SOURCE_PARAMETERS_V2; //ucEncoderID -//#define ASIC_INT_DAC1_ENCODER_ID 0x00 +//#define ASIC_INT_DAC1_ENCODER_ID 0x00 //#define ASIC_INT_TV_ENCODER_ID 0x02 //#define ASIC_INT_DIG1_ENCODER_ID 0x03 //#define ASIC_INT_DAC2_ENCODER_ID 0x04 @@ -1534,10 +1534,10 @@ typedef struct _SELECT_CRTC_SOURCE_PARAMETERS_V2 //#define ATOM_ENCODER_MODE_CV 14 //#define ATOM_ENCODER_MODE_CRT 15 -/****************************************************************************/ +/****************************************************************************/ // Structures used by SetPixelClockTable -// GetPixelClockTable -/****************************************************************************/ +// GetPixelClockTable +/****************************************************************************/ //Major revision=1., Minor revision=1 typedef struct _PIXEL_CLOCK_PARAMETERS { @@ -1545,7 +1545,7 @@ typedef struct _PIXEL_CLOCK_PARAMETERS // 0 means disable PPLL USHORT usRefDiv; // Reference divider USHORT usFbDiv; // feedback divider - UCHAR ucPostDiv; // post divider + UCHAR ucPostDiv; // post divider UCHAR ucFracFbDiv; // fractional feedback divider UCHAR ucPpll; // ATOM_PPLL1 or ATOM_PPL2 UCHAR ucRefDivSrc; // ATOM_PJITTER or ATO_NONPJITTER @@ -1565,7 +1565,7 @@ typedef struct _PIXEL_CLOCK_PARAMETERS_V2 // 0 means disable PPLL USHORT usRefDiv; // Reference divider USHORT usFbDiv; // feedback divider - UCHAR ucPostDiv; // post divider + UCHAR ucPostDiv; // post divider UCHAR ucFracFbDiv; // fractional feedback divider UCHAR ucPpll; // ATOM_PPLL1 or ATOM_PPL2 UCHAR ucRefDivSrc; // ATOM_PJITTER or ATO_NONPJITTER @@ -1612,7 +1612,7 @@ typedef struct _PIXEL_CLOCK_PARAMETERS_V3 // 0 means disable PPLL. For VGA PPLL,make sure this value is not 0. USHORT usRefDiv; // Reference divider USHORT usFbDiv; // feedback divider - UCHAR ucPostDiv; // post divider + UCHAR ucPostDiv; // post divider UCHAR ucFracFbDiv; // fractional feedback divider UCHAR ucPpll; // ATOM_PPLL1 or ATOM_PPL2 UCHAR ucTransmitterId; // graphic encoder id defined in objectId.h @@ -1631,25 +1631,25 @@ typedef struct _PIXEL_CLOCK_PARAMETERS_V3 typedef struct _PIXEL_CLOCK_PARAMETERS_V5 { - UCHAR ucCRTC; // ATOM_CRTC1~6, indicate the CRTC controller to + UCHAR ucCRTC; // ATOM_CRTC1~6, indicate the CRTC controller to // drive the pixel clock. not used for DCPLL case. union{ UCHAR ucReserved; UCHAR ucFracFbDiv; // [gphan] temporary to prevent build problem. remove it after driver code is changed. }; USHORT usPixelClock; // target the pixel clock to drive the CRTC timing - // 0 means disable PPLL/DCPLL. - USHORT usFbDiv; // feedback divider integer part. - UCHAR ucPostDiv; // post divider. + // 0 means disable PPLL/DCPLL. + USHORT usFbDiv; // feedback divider integer part. + UCHAR ucPostDiv; // post divider. UCHAR ucRefDiv; // Reference divider UCHAR ucPpll; // ATOM_PPLL1/ATOM_PPLL2/ATOM_DCPLL - UCHAR ucTransmitterID; // ASIC encoder id defined in objectId.h, - // indicate which graphic encoder will be used. - UCHAR ucEncoderMode; // Encoder mode: - UCHAR ucMiscInfo; // bit[0]= Force program PPLL - // bit[1]= when VGA timing is used. + UCHAR ucTransmitterID; // ASIC encoder id defined in objectId.h, + // indicate which graphic encoder will be used. + UCHAR ucEncoderMode; // Encoder mode: + UCHAR ucMiscInfo; // bit[0]= Force program PPLL + // bit[1]= when VGA timing is used. // bit[3:2]= HDMI panel bit depth: =0: 24bpp =1:30bpp, =2:32bpp - // bit[4]= RefClock source for PPLL. + // bit[4]= RefClock source for PPLL. // =0: XTLAIN( default mode ) // =1: other external clock source, which is pre-defined // by VBIOS depend on the feature required. @@ -1669,14 +1669,14 @@ typedef struct _PIXEL_CLOCK_PARAMETERS_V5 typedef struct _CRTC_PIXEL_CLOCK_FREQ { #if ATOM_BIG_ENDIAN - ULONG ucCRTC:8; // ATOM_CRTC1~6, indicate the CRTC controller to + ULONG ucCRTC:8; // ATOM_CRTC1~6, indicate the CRTC controller to // drive the pixel clock. not used for DCPLL case. - ULONG ulPixelClock:24; // target the pixel clock to drive the CRTC timing. + ULONG ulPixelClock:24; // target the pixel clock to drive the CRTC timing. // 0 means disable PPLL/DCPLL. Expanded to 24 bits comparing to previous version. #else - ULONG ulPixelClock:24; // target the pixel clock to drive the CRTC timing. + ULONG ulPixelClock:24; // target the pixel clock to drive the CRTC timing. // 0 means disable PPLL/DCPLL. Expanded to 24 bits comparing to previous version. - ULONG ucCRTC:8; // ATOM_CRTC1~6, indicate the CRTC controller to + ULONG ucCRTC:8; // ATOM_CRTC1~6, indicate the CRTC controller to // drive the pixel clock. not used for DCPLL case. #endif }CRTC_PIXEL_CLOCK_FREQ; @@ -1684,22 +1684,22 @@ typedef struct _CRTC_PIXEL_CLOCK_FREQ typedef struct _PIXEL_CLOCK_PARAMETERS_V6 { union{ - CRTC_PIXEL_CLOCK_FREQ ulCrtcPclkFreq; // pixel clock and CRTC id frequency + CRTC_PIXEL_CLOCK_FREQ ulCrtcPclkFreq; // pixel clock and CRTC id frequency ULONG ulDispEngClkFreq; // dispclk frequency }; - USHORT usFbDiv; // feedback divider integer part. - UCHAR ucPostDiv; // post divider. + USHORT usFbDiv; // feedback divider integer part. + UCHAR ucPostDiv; // post divider. UCHAR ucRefDiv; // Reference divider UCHAR ucPpll; // ATOM_PPLL1/ATOM_PPLL2/ATOM_DCPLL - UCHAR ucTransmitterID; // ASIC encoder id defined in objectId.h, - // indicate which graphic encoder will be used. - UCHAR ucEncoderMode; // Encoder mode: - UCHAR ucMiscInfo; // bit[0]= Force program PPLL - // bit[1]= when VGA timing is used. + UCHAR ucTransmitterID; // ASIC encoder id defined in objectId.h, + // indicate which graphic encoder will be used. + UCHAR ucEncoderMode; // Encoder mode: + UCHAR ucMiscInfo; // bit[0]= Force program PPLL + // bit[1]= when VGA timing is used. // bit[3:2]= HDMI panel bit depth: =0: 24bpp =1:30bpp, =2:32bpp - // bit[4]= RefClock source for PPLL. + // bit[4]= RefClock source for PPLL. // =0: XTLAIN( default mode ) - // =1: other external clock source, which is pre-defined + // =1: other external clock source, which is pre-defined // by VBIOS depend on the feature required. // bit[7:5]: reserved. ULONG ulFbDivDecFrac; // 20 bit feedback divider decimal fraction part, range from 1~999999 ( 0.000001 to 0.999999 ) @@ -1735,9 +1735,9 @@ typedef struct _GET_DISP_PLL_STATUS_INPUT_PARAMETERS_V3 PIXEL_CLOCK_PARAMETERS_V5 sDispClkInput; }GET_DISP_PLL_STATUS_INPUT_PARAMETERS_V3; -/****************************************************************************/ +/****************************************************************************/ // Structures used by AdjustDisplayPllTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ADJUST_DISPLAY_PLL_PARAMETERS { USHORT usPixelClock; @@ -1782,21 +1782,21 @@ typedef struct _ADJUST_DISPLAY_PLL_OUTPUT_PARAMETERS_V3 ULONG ulDispPllFreq; // return display PPLL freq which is used to generate the pixclock, and related idclk, symclk etc UCHAR ucRefDiv; // if it is none-zero, it is used to be calculated the other ppll parameter fb_divider and post_div ( if it is not given ) UCHAR ucPostDiv; // if it is none-zero, it is used to be calculated the other ppll parameter fb_divider - UCHAR ucReserved[2]; + UCHAR ucReserved[2]; }ADJUST_DISPLAY_PLL_OUTPUT_PARAMETERS_V3; typedef struct _ADJUST_DISPLAY_PLL_PS_ALLOCATION_V3 { - union + union { ADJUST_DISPLAY_PLL_INPUT_PARAMETERS_V3 sInput; ADJUST_DISPLAY_PLL_OUTPUT_PARAMETERS_V3 sOutput; }; } ADJUST_DISPLAY_PLL_PS_ALLOCATION_V3; -/****************************************************************************/ +/****************************************************************************/ // Structures used by EnableYUVTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ENABLE_YUV_PARAMETERS { UCHAR ucEnable; // ATOM_ENABLE:Enable YUV or ATOM_DISABLE:Disable YUV (RGB) @@ -1805,27 +1805,27 @@ typedef struct _ENABLE_YUV_PARAMETERS }ENABLE_YUV_PARAMETERS; #define ENABLE_YUV_PS_ALLOCATION ENABLE_YUV_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by GetMemoryClockTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _GET_MEMORY_CLOCK_PARAMETERS { ULONG ulReturnMemoryClock; // current memory speed in 10KHz unit } GET_MEMORY_CLOCK_PARAMETERS; #define GET_MEMORY_CLOCK_PS_ALLOCATION GET_MEMORY_CLOCK_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by GetEngineClockTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _GET_ENGINE_CLOCK_PARAMETERS { ULONG ulReturnEngineClock; // current engine speed in 10KHz unit } GET_ENGINE_CLOCK_PARAMETERS; #define GET_ENGINE_CLOCK_PS_ALLOCATION GET_ENGINE_CLOCK_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Following Structures and constant may be obsolete -/****************************************************************************/ +/****************************************************************************/ //Maxium 8 bytes,the data read in will be placed in the parameter space. //Read operaion successeful when the paramter space is non-zero, otherwise read operation failed typedef struct _READ_EDID_FROM_HW_I2C_DATA_PARAMETERS @@ -1850,7 +1850,7 @@ typedef struct _WRITE_ONE_BYTE_HW_I2C_DATA_PARAMETERS { USHORT usPrescale; //Ratio between Engine clock and I2C clock USHORT usByteOffset; //Write to which byte - //Upper portion of usByteOffset is Format of data + //Upper portion of usByteOffset is Format of data //1bytePS+offsetPS //2bytesPS+offsetPS //blockID+offsetPS @@ -1876,18 +1876,18 @@ typedef struct _SET_UP_HW_I2C_DATA_PARAMETERS #define SPEED_FAN_CONTROL_PS_ALLOCATION WRITE_ONE_BYTE_HW_I2C_DATA_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structures used by PowerConnectorDetectionTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _POWER_CONNECTOR_DETECTION_PARAMETERS { UCHAR ucPowerConnectorStatus; //Used for return value 0: detected, 1:not detected - UCHAR ucPwrBehaviorId; + UCHAR ucPwrBehaviorId; USHORT usPwrBudget; //how much power currently boot to in unit of watt }POWER_CONNECTOR_DETECTION_PARAMETERS; typedef struct POWER_CONNECTOR_DETECTION_PS_ALLOCATION -{ +{ UCHAR ucPowerConnectorStatus; //Used for return value 0: detected, 1:not detected UCHAR ucReserved; USHORT usPwrBudget; //how much power currently boot to in unit of watt @@ -1896,12 +1896,12 @@ typedef struct POWER_CONNECTOR_DETECTION_PS_ALLOCATION /****************************LVDS SS Command Table Definitions**********************/ -/****************************************************************************/ +/****************************************************************************/ // Structures used by EnableSpreadSpectrumOnPPLLTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ENABLE_LVDS_SS_PARAMETERS { - USHORT usSpreadSpectrumPercentage; + USHORT usSpreadSpectrumPercentage; UCHAR ucSpreadSpectrumType; //Bit1=0 Down Spread,=1 Center Spread. Bit1=1 Ext. =0 Int. Others:TBD UCHAR ucSpreadSpectrumStepSize_Delay; //bits3:2 SS_STEP_SIZE; bit 6:4 SS_DELAY UCHAR ucEnable; //ATOM_ENABLE or ATOM_DISABLE @@ -1911,7 +1911,7 @@ typedef struct _ENABLE_LVDS_SS_PARAMETERS //ucTableFormatRevision=1,ucTableContentRevision=2 typedef struct _ENABLE_LVDS_SS_PARAMETERS_V2 { - USHORT usSpreadSpectrumPercentage; + USHORT usSpreadSpectrumPercentage; UCHAR ucSpreadSpectrumType; //Bit1=0 Down Spread,=1 Center Spread. Bit1=1 Ext. =0 Int. Others:TBD UCHAR ucSpreadSpectrumStep; // UCHAR ucEnable; //ATOM_ENABLE or ATOM_DISABLE @@ -1935,12 +1935,12 @@ typedef struct _ENABLE_SPREAD_SPECTRUM_ON_PPLL typedef struct _ENABLE_SPREAD_SPECTRUM_ON_PPLL_V2 { USHORT usSpreadSpectrumPercentage; - UCHAR ucSpreadSpectrumType; // Bit[0]: 0-Down Spread,1-Center Spread. - // Bit[1]: 1-Ext. 0-Int. + UCHAR ucSpreadSpectrumType; // Bit[0]: 0-Down Spread,1-Center Spread. + // Bit[1]: 1-Ext. 0-Int. // Bit[3:2]: =0 P1PLL =1 P2PLL =2 DCPLL // Bits[7:4] reserved UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE - USHORT usSpreadSpectrumAmount; // Includes SS_AMOUNT_FBDIV[7:0] and SS_AMOUNT_NFRAC_SLIP[11:8] + USHORT usSpreadSpectrumAmount; // Includes SS_AMOUNT_FBDIV[7:0] and SS_AMOUNT_NFRAC_SLIP[11:8] USHORT usSpreadSpectrumStep; // SS_STEP_SIZE_DSFRAC }ENABLE_SPREAD_SPECTRUM_ON_PPLL_V2; @@ -1960,15 +1960,15 @@ typedef struct _ENABLE_SPREAD_SPECTRUM_ON_PPLL_V2 typedef struct _ENABLE_SPREAD_SPECTRUM_ON_PPLL_V3 { USHORT usSpreadSpectrumAmountFrac; // SS_AMOUNT_DSFRAC New in DCE5.0 - UCHAR ucSpreadSpectrumType; // Bit[0]: 0-Down Spread,1-Center Spread. - // Bit[1]: 1-Ext. 0-Int. + UCHAR ucSpreadSpectrumType; // Bit[0]: 0-Down Spread,1-Center Spread. + // Bit[1]: 1-Ext. 0-Int. // Bit[3:2]: =0 P1PLL =1 P2PLL =2 DCPLL // Bits[7:4] reserved UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE - USHORT usSpreadSpectrumAmount; // Includes SS_AMOUNT_FBDIV[7:0] and SS_AMOUNT_NFRAC_SLIP[11:8] + USHORT usSpreadSpectrumAmount; // Includes SS_AMOUNT_FBDIV[7:0] and SS_AMOUNT_NFRAC_SLIP[11:8] USHORT usSpreadSpectrumStep; // SS_STEP_SIZE_DSFRAC }ENABLE_SPREAD_SPECTRUM_ON_PPLL_V3; - + #define ATOM_PPLL_SS_TYPE_V3_DOWN_SPREAD 0x00 #define ATOM_PPLL_SS_TYPE_V3_CENTRE_SPREAD 0x01 #define ATOM_PPLL_SS_TYPE_V3_EXT_SPREAD 0x02 @@ -1989,14 +1989,14 @@ typedef struct _ENABLE_SPREAD_SPECTRUM_ON_PPLL_V2 typedef struct _SET_PIXEL_CLOCK_PS_ALLOCATION { PIXEL_CLOCK_PARAMETERS sPCLKInput; - ENABLE_SPREAD_SPECTRUM_ON_PPLL sReserved;//Caller doesn't need to init this portion + ENABLE_SPREAD_SPECTRUM_ON_PPLL sReserved;//Caller doesn't need to init this portion }SET_PIXEL_CLOCK_PS_ALLOCATION; #define ENABLE_VGA_RENDER_PS_ALLOCATION SET_PIXEL_CLOCK_PS_ALLOCATION -/****************************************************************************/ +/****************************************************************************/ // Structures used by ### -/****************************************************************************/ +/****************************************************************************/ typedef struct _MEMORY_TRAINING_PARAMETERS { ULONG ulTargetMemoryClock; //In 10Khz unit @@ -2007,11 +2007,11 @@ typedef struct _MEMORY_TRAINING_PARAMETERS /****************************LVDS and other encoder command table definitions **********************/ -/****************************************************************************/ +/****************************************************************************/ // Structures used by LVDSEncoderControlTable (Before DCE30) // LVTMAEncoderControlTable (Before DCE30) // TMDSAEncoderControlTable (Before DCE30) -/****************************************************************************/ +/****************************************************************************/ typedef struct _LVDS_ENCODER_CONTROL_PARAMETERS { USHORT usPixelClock; // in 10KHz; for bios convenient @@ -2024,7 +2024,7 @@ typedef struct _LVDS_ENCODER_CONTROL_PARAMETERS }LVDS_ENCODER_CONTROL_PARAMETERS; #define LVDS_ENCODER_CONTROL_PS_ALLOCATION LVDS_ENCODER_CONTROL_PARAMETERS - + #define TMDS1_ENCODER_CONTROL_PARAMETERS LVDS_ENCODER_CONTROL_PARAMETERS #define TMDS1_ENCODER_CONTROL_PS_ALLOCATION TMDS1_ENCODER_CONTROL_PARAMETERS @@ -2064,10 +2064,10 @@ typedef struct _LVDS_ENCODER_CONTROL_PARAMETERS_V2 }LVDS_ENCODER_CONTROL_PARAMETERS_V2; #define LVDS_ENCODER_CONTROL_PS_ALLOCATION_V2 LVDS_ENCODER_CONTROL_PARAMETERS_V2 - + #define TMDS1_ENCODER_CONTROL_PARAMETERS_V2 LVDS_ENCODER_CONTROL_PARAMETERS_V2 #define TMDS1_ENCODER_CONTROL_PS_ALLOCATION_V2 TMDS1_ENCODER_CONTROL_PARAMETERS_V2 - + #define TMDS2_ENCODER_CONTROL_PARAMETERS_V2 TMDS1_ENCODER_CONTROL_PARAMETERS_V2 #define TMDS2_ENCODER_CONTROL_PS_ALLOCATION_V2 TMDS2_ENCODER_CONTROL_PARAMETERS_V2 @@ -2080,18 +2080,18 @@ typedef struct _LVDS_ENCODER_CONTROL_PARAMETERS_V2 #define TMDS2_ENCODER_CONTROL_PARAMETERS_V3 LVDS_ENCODER_CONTROL_PARAMETERS_V3 #define TMDS2_ENCODER_CONTROL_PS_ALLOCATION_V3 TMDS2_ENCODER_CONTROL_PARAMETERS_V3 -/****************************************************************************/ +/****************************************************************************/ // Structures used by ### -/****************************************************************************/ +/****************************************************************************/ typedef struct _ENABLE_EXTERNAL_TMDS_ENCODER_PARAMETERS -{ +{ UCHAR ucEnable; // Enable or Disable External TMDS encoder UCHAR ucMisc; // Bit0=0:Enable Single link;=1:Enable Dual link;Bit1 {=0:666RGB, =1:888RGB} UCHAR ucPadding[2]; }ENABLE_EXTERNAL_TMDS_ENCODER_PARAMETERS; typedef struct _ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION -{ +{ ENABLE_EXTERNAL_TMDS_ENCODER_PARAMETERS sXTmdsEncoder; WRITE_ONE_BYTE_HW_I2C_DATA_PS_ALLOCATION sReserved; //Caller doesn't need to init this portion }ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION; @@ -2099,7 +2099,7 @@ typedef struct _ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION #define ENABLE_EXTERNAL_TMDS_ENCODER_PARAMETERS_V2 LVDS_ENCODER_CONTROL_PARAMETERS_V2 typedef struct _ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION_V2 -{ +{ ENABLE_EXTERNAL_TMDS_ENCODER_PARAMETERS_V2 sXTmdsEncoder; WRITE_ONE_BYTE_HW_I2C_DATA_PS_ALLOCATION sReserved; //Caller doesn't need to init this portion }ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION_V2; @@ -2110,9 +2110,9 @@ typedef struct _EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION WRITE_ONE_BYTE_HW_I2C_DATA_PS_ALLOCATION sReserved; }EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION; -/****************************************************************************/ +/****************************************************************************/ // Structures used by DVOEncoderControlTable -/****************************************************************************/ +/****************************************************************************/ //ucTableFormatRevision=1,ucTableContentRevision=3 //ucDVOConfig: @@ -2126,7 +2126,7 @@ typedef struct _EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION typedef struct _DVO_ENCODER_CONTROL_PARAMETERS_V3 { - USHORT usPixelClock; + USHORT usPixelClock; UCHAR ucDVOConfig; UCHAR ucAction; //ATOM_ENABLE/ATOM_DISABLE/ATOM_HPD_INIT UCHAR ucReseved[4]; @@ -2135,7 +2135,7 @@ typedef struct _DVO_ENCODER_CONTROL_PARAMETERS_V3 typedef struct _DVO_ENCODER_CONTROL_PARAMETERS_V1_4 { - USHORT usPixelClock; + USHORT usPixelClock; UCHAR ucDVOConfig; UCHAR ucAction; //ATOM_ENABLE/ATOM_DISABLE/ATOM_HPD_INIT UCHAR ucBitPerColor; //please refer to definition of PANEL_xBIT_PER_COLOR @@ -2145,7 +2145,7 @@ typedef struct _DVO_ENCODER_CONTROL_PARAMETERS_V1_4 //ucTableFormatRevision=1 -//ucTableContentRevision=3 structure is not changed but usMisc add bit 1 as another input for +//ucTableContentRevision=3 structure is not changed but usMisc add bit 1 as another input for // bit1=0: non-coherent mode // =1: coherent mode @@ -2192,9 +2192,9 @@ typedef struct _DVO_ENCODER_CONTROL_PARAMETERS_V1_4 #define PANEL_ENCODER_75FRC_E 0x00 #define PANEL_ENCODER_75FRC_F 0x80 -/****************************************************************************/ +/****************************************************************************/ // Structures used by SetVoltageTable -/****************************************************************************/ +/****************************************************************************/ #define SET_VOLTAGE_TYPE_ASIC_VDDC 1 #define SET_VOLTAGE_TYPE_ASIC_MVDDC 2 #define SET_VOLTAGE_TYPE_ASIC_MVDDQ 3 @@ -2215,7 +2215,7 @@ typedef struct _SET_VOLTAGE_PARAMETERS UCHAR ucVoltageType; // To tell which voltage to set up, VDDC/MVDDC/MVDDQ UCHAR ucVoltageMode; // To set all, to set source A or source B or ... UCHAR ucVoltageIndex; // An index to tell which voltage level - UCHAR ucReserved; + UCHAR ucReserved; }SET_VOLTAGE_PARAMETERS; typedef struct _SET_VOLTAGE_PARAMETERS_V2 @@ -2245,7 +2245,7 @@ typedef struct _SET_VOLTAGE_PARAMETERS_V1_3 #define ATOM_SET_VOLTAGE_PHASE 4 //Set Vregulator Phase, only for SVID/PVID regulator #define ATOM_GET_MAX_VOLTAGE 6 //Get Max Voltage, not used from SetVoltageTable v1.3 #define ATOM_GET_VOLTAGE_LEVEL 6 //Get Voltage level from vitual voltage ID, not used for SetVoltage v1.4 -#define ATOM_GET_LEAKAGE_ID 8 //Get Leakage Voltage Id ( starting from SMU7x IP ), SetVoltage v1.4 +#define ATOM_GET_LEAKAGE_ID 8 //Get Leakage Voltage Id ( starting from SMU7x IP ), SetVoltage v1.4 // define vitual voltage id in usVoltageLevel #define ATOM_VIRTUAL_VOLTAGE_ID0 0xff01 @@ -2268,7 +2268,7 @@ typedef struct _GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_1 { UCHAR ucVoltageType; // Input: To tell which voltage to set up, VDDC/MVDDC/MVDDQ/VDDCI UCHAR ucVoltageMode; // Input: Indicate action: Get voltage info - USHORT usVoltageLevel; // Input: real voltage level in unit of mv or Voltage Phase (0, 1, 2, .. ) or Leakage Id + USHORT usVoltageLevel; // Input: real voltage level in unit of mv or Voltage Phase (0, 1, 2, .. ) or Leakage Id ULONG ulReserved; }GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_1; @@ -2307,14 +2307,14 @@ typedef struct _GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2 { UCHAR ucVoltageType; // Input: To tell which voltage to set up, VDDC/MVDDC/MVDDQ/VDDCI UCHAR ucVoltageMode; // Input: Indicate action: Get voltage info - USHORT usVoltageLevel; // Input: real voltage level in unit of mv or Voltage Phase (0, 1, 2, .. ) or Leakage Id + USHORT usVoltageLevel; // Input: real voltage level in unit of mv or Voltage Phase (0, 1, 2, .. ) or Leakage Id ULONG ulSCLKFreq; // Input: when ucVoltageMode= ATOM_GET_VOLTAGE_EVV_VOLTAGE, DPM state SCLK frequency, Define in PPTable SCLK/Voltage dependence table }GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2; // New in GetVoltageInfo v1.2 ucVoltageMode -#define ATOM_GET_VOLTAGE_EVV_VOLTAGE 0x09 +#define ATOM_GET_VOLTAGE_EVV_VOLTAGE 0x09 -// New Added from CI Hawaii for EVV feature +// New Added from CI Hawaii for EVV feature typedef struct _GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_2 { USHORT usVoltageLevel; // real voltage level in unit of mv @@ -2322,9 +2322,9 @@ typedef struct _GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_2 ULONG ulReseved; }GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_2; -/****************************************************************************/ +/****************************************************************************/ // Structures used by TVEncoderControlTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _TV_ENCODER_CONTROL_PARAMETERS { USHORT usPixelClock; // in 10KHz; for bios convenient @@ -2335,28 +2335,28 @@ typedef struct _TV_ENCODER_CONTROL_PARAMETERS typedef struct _TV_ENCODER_CONTROL_PS_ALLOCATION { - TV_ENCODER_CONTROL_PARAMETERS sTVEncoder; + TV_ENCODER_CONTROL_PARAMETERS sTVEncoder; WRITE_ONE_BYTE_HW_I2C_DATA_PS_ALLOCATION sReserved; // Don't set this one }TV_ENCODER_CONTROL_PS_ALLOCATION; //==============================Data Table Portion==================================== -/****************************************************************************/ +/****************************************************************************/ // Structure used in Data.mtb -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_MASTER_LIST_OF_DATA_TABLES { USHORT UtilityPipeLine; // Offest for the utility to get parser info,Don't change this position! - USHORT MultimediaCapabilityInfo; // Only used by MM Lib,latest version 1.1, not configuable from Bios, need to include the table to build Bios + USHORT MultimediaCapabilityInfo; // Only used by MM Lib,latest version 1.1, not configuable from Bios, need to include the table to build Bios USHORT MultimediaConfigInfo; // Only used by MM Lib,latest version 2.1, not configuable from Bios, need to include the table to build Bios USHORT StandardVESA_Timing; // Only used by Bios USHORT FirmwareInfo; // Shared by various SW components,latest version 1.4 USHORT PaletteData; // Only used by BIOS - USHORT LCD_Info; // Shared by various SW components,latest version 1.3, was called LVDS_Info + USHORT LCD_Info; // Shared by various SW components,latest version 1.3, was called LVDS_Info USHORT DIGTransmitterInfo; // Internal used by VBIOS only version 3.1 - USHORT AnalogTV_Info; // Shared by various SW components,latest version 1.1 + USHORT AnalogTV_Info; // Shared by various SW components,latest version 1.1 USHORT SupportedDevicesInfo; // Will be obsolete from R600 - USHORT GPIO_I2C_Info; // Shared by various SW components,latest version 1.2 will be used from R600 + USHORT GPIO_I2C_Info; // Shared by various SW components,latest version 1.2 will be used from R600 USHORT VRAM_UsageByFirmware; // Shared by various SW components,latest version 1.3 will be used from R600 USHORT GPIO_Pin_LUT; // Shared by various SW components,latest version 1.1 USHORT VESA_ToInternalModeLUT; // Only used by Bios @@ -2383,22 +2383,22 @@ typedef struct _ATOM_MASTER_LIST_OF_DATA_TABLES }ATOM_MASTER_LIST_OF_DATA_TABLES; typedef struct _ATOM_MASTER_DATA_TABLE -{ - ATOM_COMMON_TABLE_HEADER sHeader; +{ + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_MASTER_LIST_OF_DATA_TABLES ListOfDataTables; }ATOM_MASTER_DATA_TABLE; -// For backward compatible +// For backward compatible #define LVDS_Info LCD_Info #define DAC_Info PaletteData #define TMDS_Info DIGTransmitterInfo -/****************************************************************************/ +/****************************************************************************/ // Structure used in MultimediaCapabilityInfoTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_MULTIMEDIA_CAPABILITY_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulSignature; // HW info table signature string "$ATI" UCHAR ucI2C_Type; // I2C type (normal GP_IO, ImpactTV GP_IO, Dedicated I2C pin, etc) UCHAR ucTV_OutInfo; // Type of TV out supported (3:0) and video out crystal frequency (6:4) and TV data port (7) @@ -2406,9 +2406,9 @@ typedef struct _ATOM_MULTIMEDIA_CAPABILITY_INFO UCHAR ucHostPortInfo; // Provides host port configuration information }ATOM_MULTIMEDIA_CAPABILITY_INFO; -/****************************************************************************/ +/****************************************************************************/ // Structure used in MultimediaConfigInfoTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_MULTIMEDIA_CONFIG_INFO { ATOM_COMMON_TABLE_HEADER sHeader; @@ -2428,20 +2428,20 @@ typedef struct _ATOM_MULTIMEDIA_CONFIG_INFO }ATOM_MULTIMEDIA_CONFIG_INFO; -/****************************************************************************/ +/****************************************************************************/ // Structures used in FirmwareInfoTable -/****************************************************************************/ +/****************************************************************************/ // usBIOSCapability Definition: -// Bit 0 = 0: Bios image is not Posted, =1:Bios image is Posted; -// Bit 1 = 0: Dual CRTC is not supported, =1: Dual CRTC is supported; -// Bit 2 = 0: Extended Desktop is not supported, =1: Extended Desktop is supported; +// Bit 0 = 0: Bios image is not Posted, =1:Bios image is Posted; +// Bit 1 = 0: Dual CRTC is not supported, =1: Dual CRTC is supported; +// Bit 2 = 0: Extended Desktop is not supported, =1: Extended Desktop is supported; // Others: Reserved #define ATOM_BIOS_INFO_ATOM_FIRMWARE_POSTED 0x0001 #define ATOM_BIOS_INFO_DUAL_CRTC_SUPPORT 0x0002 #define ATOM_BIOS_INFO_EXTENDED_DESKTOP_SUPPORT 0x0004 -#define ATOM_BIOS_INFO_MEMORY_CLOCK_SS_SUPPORT 0x0008 // (valid from v1.1 ~v1.4):=1: memclk SS enable, =0 memclk SS disable. -#define ATOM_BIOS_INFO_ENGINE_CLOCK_SS_SUPPORT 0x0010 // (valid from v1.1 ~v1.4):=1: engclk SS enable, =0 engclk SS disable. +#define ATOM_BIOS_INFO_MEMORY_CLOCK_SS_SUPPORT 0x0008 // (valid from v1.1 ~v1.4):=1: memclk SS enable, =0 memclk SS disable. +#define ATOM_BIOS_INFO_ENGINE_CLOCK_SS_SUPPORT 0x0010 // (valid from v1.1 ~v1.4):=1: engclk SS enable, =0 engclk SS disable. #define ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU 0x0020 #define ATOM_BIOS_INFO_WMI_SUPPORT 0x0040 #define ATOM_BIOS_INFO_PPMODE_ASSIGNGED_BY_SYSTEM 0x0080 @@ -2505,7 +2505,7 @@ typedef union _ATOM_FIRMWARE_CAPABILITY_ACCESS typedef struct _ATOM_FIRMWARE_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulFirmwareRevision; ULONG ulDefaultEngineClock; //In 10Khz unit ULONG ulDefaultMemoryClock; //In 10Khz unit @@ -2530,8 +2530,8 @@ typedef struct _ATOM_FIRMWARE_INFO USHORT usMaxPixelClockPLL_Input; //In 10Khz unit USHORT usMinPixelClockPLL_Output; //In 10Khz unit, the definitions above can't change!!! ATOM_FIRMWARE_CAPABILITY_ACCESS usFirmwareCapability; - USHORT usReferenceClock; //In 10Khz unit - USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit + USHORT usReferenceClock; //In 10Khz unit + USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit UCHAR ucPM_RTS_StreamSize; //RTS PM4 packets in Kb unit UCHAR ucDesign_ID; //Indicate what is the board design UCHAR ucMemoryModule_ID; //Indicate what is the board design @@ -2539,7 +2539,7 @@ typedef struct _ATOM_FIRMWARE_INFO typedef struct _ATOM_FIRMWARE_INFO_V1_2 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulFirmwareRevision; ULONG ulDefaultEngineClock; //In 10Khz unit ULONG ulDefaultMemoryClock; //In 10Khz unit @@ -2566,8 +2566,8 @@ typedef struct _ATOM_FIRMWARE_INFO_V1_2 USHORT usMaxPixelClockPLL_Input; //In 10Khz unit USHORT usMinPixelClockPLL_Output; //In 10Khz unit - lower 16bit of ulMinPixelClockPLL_Output ATOM_FIRMWARE_CAPABILITY_ACCESS usFirmwareCapability; - USHORT usReferenceClock; //In 10Khz unit - USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit + USHORT usReferenceClock; //In 10Khz unit + USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit UCHAR ucPM_RTS_StreamSize; //RTS PM4 packets in Kb unit UCHAR ucDesign_ID; //Indicate what is the board design UCHAR ucMemoryModule_ID; //Indicate what is the board design @@ -2575,7 +2575,7 @@ typedef struct _ATOM_FIRMWARE_INFO_V1_2 typedef struct _ATOM_FIRMWARE_INFO_V1_3 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulFirmwareRevision; ULONG ulDefaultEngineClock; //In 10Khz unit ULONG ulDefaultMemoryClock; //In 10Khz unit @@ -2603,8 +2603,8 @@ typedef struct _ATOM_FIRMWARE_INFO_V1_3 USHORT usMaxPixelClockPLL_Input; //In 10Khz unit USHORT usMinPixelClockPLL_Output; //In 10Khz unit - lower 16bit of ulMinPixelClockPLL_Output ATOM_FIRMWARE_CAPABILITY_ACCESS usFirmwareCapability; - USHORT usReferenceClock; //In 10Khz unit - USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit + USHORT usReferenceClock; //In 10Khz unit + USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit UCHAR ucPM_RTS_StreamSize; //RTS PM4 packets in Kb unit UCHAR ucDesign_ID; //Indicate what is the board design UCHAR ucMemoryModule_ID; //Indicate what is the board design @@ -2612,7 +2612,7 @@ typedef struct _ATOM_FIRMWARE_INFO_V1_3 typedef struct _ATOM_FIRMWARE_INFO_V1_4 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulFirmwareRevision; ULONG ulDefaultEngineClock; //In 10Khz unit ULONG ulDefaultMemoryClock; //In 10Khz unit @@ -2641,8 +2641,8 @@ typedef struct _ATOM_FIRMWARE_INFO_V1_4 USHORT usMaxPixelClockPLL_Input; //In 10Khz unit USHORT usMinPixelClockPLL_Output; //In 10Khz unit - lower 16bit of ulMinPixelClockPLL_Output ATOM_FIRMWARE_CAPABILITY_ACCESS usFirmwareCapability; - USHORT usReferenceClock; //In 10Khz unit - USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit + USHORT usReferenceClock; //In 10Khz unit + USHORT usPM_RTS_Location; //RTS PM4 starting location in ROM in 1Kb unit UCHAR ucPM_RTS_StreamSize; //RTS PM4 packets in Kb unit UCHAR ucDesign_ID; //Indicate what is the board design UCHAR ucMemoryModule_ID; //Indicate what is the board design @@ -2651,7 +2651,7 @@ typedef struct _ATOM_FIRMWARE_INFO_V1_4 //the structure below to be used from Cypress typedef struct _ATOM_FIRMWARE_INFO_V2_1 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulFirmwareRevision; ULONG ulDefaultEngineClock; //In 10Khz unit ULONG ulDefaultMemoryClock; //In 10Khz unit @@ -2680,8 +2680,8 @@ typedef struct _ATOM_FIRMWARE_INFO_V2_1 USHORT usMaxPixelClockPLL_Input; //In 10Khz unit USHORT usMinPixelClockPLL_Output; //In 10Khz unit - lower 16bit of ulMinPixelClockPLL_Output ATOM_FIRMWARE_CAPABILITY_ACCESS usFirmwareCapability; - USHORT usCoreReferenceClock; //In 10Khz unit - USHORT usMemoryReferenceClock; //In 10Khz unit + USHORT usCoreReferenceClock; //In 10Khz unit + USHORT usMemoryReferenceClock; //In 10Khz unit USHORT usUniphyDPModeExtClkFreq; //In 10Khz unit, if it is 0, In DP Mode Uniphy Input clock from internal PPLL, otherwise Input clock from external Spread clock UCHAR ucMemoryModule_ID; //Indicate what is the board design UCHAR ucReserved4[3]; @@ -2692,17 +2692,17 @@ typedef struct _ATOM_FIRMWARE_INFO_V2_1 //ucTableContentRevision=2 typedef struct _ATOM_FIRMWARE_INFO_V2_2 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulFirmwareRevision; ULONG ulDefaultEngineClock; //In 10Khz unit ULONG ulDefaultMemoryClock; //In 10Khz unit - ULONG ulSPLL_OutputFreq; //In 10Khz unit + ULONG ulSPLL_OutputFreq; //In 10Khz unit ULONG ulGPUPLL_OutputFreq; //In 10Khz unit ULONG ulReserved1; //Was ulMaxEngineClockPLL_Output; //In 10Khz unit* ULONG ulReserved2; //Was ulMaxMemoryClockPLL_Output; //In 10Khz unit* ULONG ulMaxPixelClockPLL_Output; //In 10Khz unit ULONG ulBinaryAlteredInfo; //Was ulASICMaxEngineClock ? - ULONG ulDefaultDispEngineClkFreq; //In 10Khz unit. This is the frequency before DCDTO, corresponding to usBootUpVDDCVoltage. + ULONG ulDefaultDispEngineClkFreq; //In 10Khz unit. This is the frequency before DCDTO, corresponding to usBootUpVDDCVoltage. UCHAR ucReserved3; //Was ucASICMaxTemperature; UCHAR ucMinAllowedBL_Level; USHORT usBootUpVDDCVoltage; //In MV unit @@ -2719,8 +2719,8 @@ typedef struct _ATOM_FIRMWARE_INFO_V2_2 USHORT usMaxPixelClockPLL_Input; //In 10Khz unit USHORT usBootUpVDDCIVoltage; //In unit of mv; Was usMinPixelClockPLL_Output; ATOM_FIRMWARE_CAPABILITY_ACCESS usFirmwareCapability; - USHORT usCoreReferenceClock; //In 10Khz unit - USHORT usMemoryReferenceClock; //In 10Khz unit + USHORT usCoreReferenceClock; //In 10Khz unit + USHORT usMemoryReferenceClock; //In 10Khz unit USHORT usUniphyDPModeExtClkFreq; //In 10Khz unit, if it is 0, In DP Mode Uniphy Input clock from internal PPLL, otherwise Input clock from external Spread clock UCHAR ucMemoryModule_ID; //Indicate what is the board design UCHAR ucReserved9[3]; @@ -2736,9 +2736,9 @@ typedef struct _ATOM_FIRMWARE_INFO_V2_2 #define REMOTE_DISPLAY_DISABLE 0x00 #define REMOTE_DISPLAY_ENABLE 0x01 -/****************************************************************************/ +/****************************************************************************/ // Structures used in IntegratedSystemInfoTable -/****************************************************************************/ +/****************************************************************************/ #define IGP_CAP_FLAG_DYNAMIC_CLOCK_EN 0x2 #define IGP_CAP_FLAG_AC_CARD 0x4 #define IGP_CAP_FLAG_SDVO_CARD 0x8 @@ -2746,7 +2746,7 @@ typedef struct _ATOM_FIRMWARE_INFO_V2_2 typedef struct _ATOM_INTEGRATED_SYSTEM_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulBootUpEngineClock; //in 10kHz unit ULONG ulBootUpMemoryClock; //in 10kHz unit ULONG ulMaxSystemMemoryClock; //in 10kHz unit @@ -2754,8 +2754,8 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO UCHAR ucNumberOfCyclesInPeriodHi; UCHAR ucLCDTimingSel; //=0:not valid.!=0 sel this timing descriptor from LCD EDID. USHORT usReserved1; - USHORT usInterNBVoltageLow; //An intermidiate PMW value to set the voltage - USHORT usInterNBVoltageHigh; //Another intermidiate PMW value to set the voltage + USHORT usInterNBVoltageLow; //An intermidiate PMW value to set the voltage + USHORT usInterNBVoltageHigh; //Another intermidiate PMW value to set the voltage ULONG ulReserved[2]; USHORT usFSBClock; //In MHz unit @@ -2769,22 +2769,22 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO UCHAR ucMaxNBVoltage; UCHAR ucMinNBVoltage; UCHAR ucMemoryType; //[7:4]=1:DDR1;=2:DDR2;=3:DDR3.[3:0] is reserved - UCHAR ucNumberOfCyclesInPeriod; //CG.FVTHROT_PWM_CTRL_REG0.NumberOfCyclesInPeriod + UCHAR ucNumberOfCyclesInPeriod; //CG.FVTHROT_PWM_CTRL_REG0.NumberOfCyclesInPeriod UCHAR ucStartingPWM_HighTime; //CG.FVTHROT_PWM_CTRL_REG0.StartingPWM_HighTime UCHAR ucHTLinkWidth; //16 bit vs. 8 bit - UCHAR ucMaxNBVoltageHigh; + UCHAR ucMaxNBVoltageHigh; UCHAR ucMinNBVoltageHigh; }ATOM_INTEGRATED_SYSTEM_INFO; /* Explanation on entries in ATOM_INTEGRATED_SYSTEM_INFO -ulBootUpMemoryClock: For Intel IGP,it's the UMA system memory clock +ulBootUpMemoryClock: For Intel IGP,it's the UMA system memory clock For AMD IGP,it's 0 if no SidePort memory installed or it's the boot-up SidePort memory clock ulMaxSystemMemoryClock: For Intel IGP,it's the Max freq from memory SPD if memory runs in ASYNC mode or otherwise (SYNC mode) it's 0 For AMD IGP,for now this can be 0 -ulMinSystemMemoryClock: For Intel IGP,it's 133MHz if memory runs in ASYNC mode or otherwise (SYNC mode) it's 0 +ulMinSystemMemoryClock: For Intel IGP,it's 133MHz if memory runs in ASYNC mode or otherwise (SYNC mode) it's 0 For AMD IGP,for now this can be 0 -usFSBClock: For Intel IGP,it's FSB Freq +usFSBClock: For Intel IGP,it's FSB Freq For AMD IGP,it's HT Link Speed usK8MemoryClock: For AMD IGP only. For RevF CPU, set it to 200 @@ -2795,8 +2795,8 @@ VC:Voltage Control ucMaxNBVoltage: Voltage regulator dependent PWM value. Low 8 bits of the value for the max voltage.Set this one to 0xFF if VC without PWM. Set this to 0x0 if no VC at all. ucMinNBVoltage: Voltage regulator dependent PWM value. Low 8 bits of the value for the min voltage.Set this one to 0x00 if VC without PWM or no VC at all. -ucNumberOfCyclesInPeriod: Indicate how many cycles when PWM duty is 100%. low 8 bits of the value. -ucNumberOfCyclesInPeriodHi: Indicate how many cycles when PWM duty is 100%. high 8 bits of the value.If the PWM has an inverter,set bit [7]==1,otherwise set it 0 +ucNumberOfCyclesInPeriod: Indicate how many cycles when PWM duty is 100%. low 8 bits of the value. +ucNumberOfCyclesInPeriodHi: Indicate how many cycles when PWM duty is 100%. high 8 bits of the value.If the PWM has an inverter,set bit [7]==1,otherwise set it 0 ucMaxNBVoltageHigh: Voltage regulator dependent PWM value. High 8 bits of the value for the max voltage.Set this one to 0xFF if VC without PWM. Set this to 0x0 if no VC at all. ucMinNBVoltageHigh: Voltage regulator dependent PWM value. High 8 bits of the value for the min voltage.Set this one to 0x00 if VC without PWM or no VC at all. @@ -2809,7 +2809,7 @@ usInterNBVoltageHigh: Voltage regulator dependent PWM value. The value makes t /* The following IGP table is introduced from RS780, which is supposed to be put by SBIOS in FB before IGP VBIOS starts VPOST; -Then VBIOS will copy the whole structure to its image so all GPU SW components can access this data structure to get whatever they need. +Then VBIOS will copy the whole structure to its image so all GPU SW components can access this data structure to get whatever they need. The enough reservation should allow us to never change table revisions. Whenever needed, a GPU SW component can use reserved portion for new data entries. SW components can access the IGP system infor structure in the same way as before @@ -2856,23 +2856,23 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 USHORT usFirmwareVersion; //0 means FW is not supported. Otherwise it's the FW version loaded by SBIOS and driver should enable FW. USHORT usFullT0Time; // Input to calculate minimum HT link change time required by NB P-State. Unit is 0.01us. ULONG ulReserved3[96]; //must be 0x0 -}ATOM_INTEGRATED_SYSTEM_INFO_V2; +}ATOM_INTEGRATED_SYSTEM_INFO_V2; /* ulBootUpEngineClock: Boot-up Engine Clock in 10Khz; ulBootUpUMAClock: Boot-up UMA Clock in 10Khz; it must be 0x0 when UMA is not present ulBootUpSidePortClock: Boot-up SidePort Clock in 10Khz; it must be 0x0 when SidePort Memory is not present,this could be equal to or less than maximum supported Sideport memory clock -ulSystemConfig: -Bit[0]=1: PowerExpress mode =0 Non-PowerExpress mode; +ulSystemConfig: +Bit[0]=1: PowerExpress mode =0 Non-PowerExpress mode; Bit[1]=1: system boots up at AMD overdrived state or user customized mode. In this case, driver will just stick to this boot-up mode. No other PowerPlay state =0: system boots up at driver control state. Power state depends on PowerPlay table. Bit[2]=1: PWM method is used on NB voltage control. =0: GPIO method is used. Bit[3]=1: Only one power state(Performance) will be supported. =0: Multiple power states supported from PowerPlay table. -Bit[4]=1: CLMC is supported and enabled on current system. - =0: CLMC is not supported or enabled on current system. SBIOS need to support HT link/freq change through ATIF interface. -Bit[5]=1: Enable CDLW for all driver control power states. Max HT width is from SBIOS, while Min HT width is determined by display requirement. +Bit[4]=1: CLMC is supported and enabled on current system. + =0: CLMC is not supported or enabled on current system. SBIOS need to support HT link/freq change through ATIF interface. +Bit[5]=1: Enable CDLW for all driver control power states. Max HT width is from SBIOS, while Min HT width is determined by display requirement. =0: CDLW is disabled. If CLMC is enabled case, Min HT width will be set equal to Max HT width. If CLMC disabled case, Max HT width will be applied. Bit[6]=1: High Voltage requested for all power states. In this case, voltage will be forced at 1.1v and powerplay table voltage drop/throttling request will be ignored. =0: Voltage settings is determined by powerplay table. @@ -2895,7 +2895,7 @@ ulDDISlot1Config: Describes the PCIE lane configuration on this DDI PCIE slot (A in both chassis and docking, SBIOS has to duplicate the same PCIE lane info from chassis to docking or vice versa. For example: one DDI connector is only populated in docking with PCIE lane 8-11, but there is no paired connection on chassis, SBIOS has to copy bit 6 to bit 2. - [15:8] - Lane configuration attribute; + [15:8] - Lane configuration attribute; [23:16]- Connector type, possible value: CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D @@ -2910,7 +2910,7 @@ For IGP, Hypermemory is the only memory type showed in CCC. ucUMAChannelNumber: how many channels for the UMA; -ulDockingPinCFGInfo: [15:0]-Bus/Device/Function # to CFG to read this Docking Pin; [31:16]-reg offset in CFG to read this pin +ulDockingPinCFGInfo: [15:0]-Bus/Device/Function # to CFG to read this Docking Pin; [31:16]-reg offset in CFG to read this pin ucDockingPinBit: which bit in this register to read the pin status; ucDockingPinPolarity:Polarity of the pin when docked; @@ -2918,7 +2918,7 @@ ulCPUCapInfo: [7:0]=1:Griffin;[7:0]=2:Greyhound;[7:0]=3:K8, [7:0]=4:Phara usNumberOfCyclesInPeriod:Indicate how many cycles when PWM duty is 100%. -usMaxNBVoltage:Max. voltage control value in either PWM or GPIO mode. +usMaxNBVoltage:Max. voltage control value in either PWM or GPIO mode. usMinNBVoltage:Min. voltage control value in either PWM or GPIO mode. GPIO mode: both usMaxNBVoltage & usMinNBVoltage have a valid value ulSystemConfig.SYSTEM_CONFIG_USE_PWM_ON_VOLTAGE=0 PWM mode: both usMaxNBVoltage & usMinNBVoltage have a valid value ulSystemConfig.SYSTEM_CONFIG_USE_PWM_ON_VOLTAGE=1 @@ -2927,14 +2927,14 @@ usMinNBVoltage:Min. voltage control value in either PWM or GPIO mode. usBootUpNBVoltage:Boot-up voltage regulator dependent PWM value. ulHTLinkFreq: Bootup HT link Frequency in 10Khz. -usMinHTLinkWidth: Bootup minimum HT link width. If CDLW disabled, this is equal to usMaxHTLinkWidth. +usMinHTLinkWidth: Bootup minimum HT link width. If CDLW disabled, this is equal to usMaxHTLinkWidth. + If CDLW enabled, both upstream and downstream width should be the same during bootup. +usMaxHTLinkWidth: Bootup maximum HT link width. If CDLW disabled, this is equal to usMinHTLinkWidth. If CDLW enabled, both upstream and downstream width should be the same during bootup. -usMaxHTLinkWidth: Bootup maximum HT link width. If CDLW disabled, this is equal to usMinHTLinkWidth. - If CDLW enabled, both upstream and downstream width should be the same during bootup. -usUMASyncStartDelay: Memory access latency, required for watermark calculation +usUMASyncStartDelay: Memory access latency, required for watermark calculation usUMADataReturnTime: Memory access latency, required for watermark calculation -usLinkStatusZeroTime:Memory access latency required for watermark calculation, set this to 0x0 for K8 CPU, set a proper value in 0.01 the unit of us +usLinkStatusZeroTime:Memory access latency required for watermark calculation, set this to 0x0 for K8 CPU, set a proper value in 0.01 the unit of us for Griffin or Greyhound. SBIOS needs to convert to actual time by: if T0Ttime [5:4]=00b, then usLinkStatusZeroTime=T0Ttime [3:0]*0.1us (0.0 to 1.5us) if T0Ttime [5:4]=01b, then usLinkStatusZeroTime=T0Ttime [3:0]*0.5us (0.0 to 7.5us) @@ -2942,7 +2942,7 @@ for Griffin or Greyhound. SBIOS needs to convert to actual time by: if T0Ttime [5:4]=11b, and T0Ttime [3:0]=0x0 to 0xa, then usLinkStatusZeroTime=T0Ttime [3:0]*20us (0.0 to 200us) ulHighVoltageHTLinkFreq: HT link frequency for power state with low voltage. If boot up runs in HT1, this must be 0. - This must be less than or equal to ulHTLinkFreq(bootup frequency). + This must be less than or equal to ulHTLinkFreq(bootup frequency). ulLowVoltageHTLinkFreq: HT link frequency for power state with low voltage or voltage scaling 1.0v~1.1v. If boot up runs in HT1, this must be 0. This must be less than or equal to ulHighVoltageHTLinkFreq. @@ -2952,7 +2952,7 @@ usMinUpStreamHTLinkWidth: Asymmetric link width support in the future, to rep usMinDownStreamHTLinkWidth: same as above. */ -// ATOM_INTEGRATED_SYSTEM_INFO::ulCPUCapInfo - CPU type definition +// ATOM_INTEGRATED_SYSTEM_INFO::ulCPUCapInfo - CPU type definition #define INTEGRATED_SYSTEM_INFO__UNKNOWN_CPU 0 #define INTEGRATED_SYSTEM_INFO__AMD_CPU__GRIFFIN 1 #define INTEGRATED_SYSTEM_INFO__AMD_CPU__GREYHOUND 2 @@ -2964,7 +2964,7 @@ usMinDownStreamHTLinkWidth: same as above. #define SYSTEM_CONFIG_POWEREXPRESS_ENABLE 0x00000001 #define SYSTEM_CONFIG_RUN_AT_OVERDRIVE_ENGINE 0x00000002 -#define SYSTEM_CONFIG_USE_PWM_ON_VOLTAGE 0x00000004 +#define SYSTEM_CONFIG_USE_PWM_ON_VOLTAGE 0x00000004 #define SYSTEM_CONFIG_PERFORMANCE_POWERSTATE_ONLY 0x00000008 #define SYSTEM_CONFIG_CLMC_ENABLED 0x00000010 #define SYSTEM_CONFIG_CDLW_ENABLED 0x00000020 @@ -2993,7 +2993,7 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V5 { ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulBootUpEngineClock; //in 10kHz unit - ULONG ulDentistVCOFreq; //Dentist VCO clock in 10kHz unit, the source of GPU SCLK, LCLK, UCLK and VCLK. + ULONG ulDentistVCOFreq; //Dentist VCO clock in 10kHz unit, the source of GPU SCLK, LCLK, UCLK and VCLK. ULONG ulLClockFreq; //GPU Lclk freq in 10kHz unit, have relationship with NCLK in NorthBridge ULONG ulBootUpUMAClock; //in 10kHz unit ULONG ulReserved1[8]; //must be 0x0 for the reserved @@ -3021,7 +3021,7 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V5 ULONG ulCSR_M3_ARB_CNTL_UVD[10]; //arrays with values for CSR M3 arbiter for UVD playback ULONG ulCSR_M3_ARB_CNTL_FS3D[10];//arrays with values for CSR M3 arbiter for Full Screen 3D applications ULONG ulReserved6[61]; //must be 0x0 -}ATOM_INTEGRATED_SYSTEM_INFO_V5; +}ATOM_INTEGRATED_SYSTEM_INFO_V5; #define ATOM_CRT_INT_ENCODER1_INDEX 0x00000000 #define ATOM_LCD_INT_ENCODER1_INDEX 0x00000001 @@ -3039,7 +3039,7 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V5 #define ATOM_DFP_INT_ENCODER4_INDEX 0x0000000D // define ASIC internal encoder id ( bit vector ), used for CRTC_SourceSelTable -#define ASIC_INT_DAC1_ENCODER_ID 0x00 +#define ASIC_INT_DAC1_ENCODER_ID 0x00 #define ASIC_INT_TV_ENCODER_ID 0x02 #define ASIC_INT_DIG1_ENCODER_ID 0x03 #define ASIC_INT_DAC2_ENCODER_ID 0x04 @@ -3056,15 +3056,15 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V5 //define Encoder attribute #define ATOM_ANALOG_ENCODER 0 -#define ATOM_DIGITAL_ENCODER 1 -#define ATOM_DP_ENCODER 2 +#define ATOM_DIGITAL_ENCODER 1 +#define ATOM_DP_ENCODER 2 #define ATOM_ENCODER_ENUM_MASK 0x70 #define ATOM_ENCODER_ENUM_ID1 0x00 #define ATOM_ENCODER_ENUM_ID2 0x10 #define ATOM_ENCODER_ENUM_ID3 0x20 #define ATOM_ENCODER_ENUM_ID4 0x30 -#define ATOM_ENCODER_ENUM_ID5 0x40 +#define ATOM_ENCODER_ENUM_ID5 0x40 #define ATOM_ENCODER_ENUM_ID6 0x50 #define ATOM_DEVICE_CRT1_INDEX 0x00000000 @@ -3162,8 +3162,8 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V5 // Bit 9 = 0 - no DFP3 support= 1- DFP3 is supported // Bit 10 = 0 - no DFP4 support= 1- DFP4 is supported // Bit 11 = 0 - no DFP5 support= 1- DFP5 is supported -// -// +// +// /****************************************************************************/ /* Structure used in MclkSS_InfoTable */ @@ -3196,11 +3196,11 @@ typedef union _ATOM_I2C_ID_CONFIG_ACCESS ATOM_I2C_ID_CONFIG sbfAccess; UCHAR ucAccess; }ATOM_I2C_ID_CONFIG_ACCESS; - -/****************************************************************************/ + +/****************************************************************************/ // Structure used in GPIO_I2C_InfoTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_GPIO_I2C_ASSIGMENT { USHORT usClkMaskRegisterIndex; @@ -3225,20 +3225,20 @@ typedef struct _ATOM_GPIO_I2C_ASSIGMENT }ATOM_GPIO_I2C_ASSIGMENT; typedef struct _ATOM_GPIO_I2C_INFO -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; ATOM_GPIO_I2C_ASSIGMENT asGPIO_Info[ATOM_MAX_SUPPORTED_DEVICE]; }ATOM_GPIO_I2C_INFO; -/****************************************************************************/ +/****************************************************************************/ // Common Structure used in other structures -/****************************************************************************/ +/****************************************************************************/ #ifndef _H2INC - + //Please don't add or expand this bitfield structure below, this one will retire soon.! typedef struct _ATOM_MODE_MISC_INFO -{ +{ #if ATOM_BIG_ENDIAN USHORT Reserved:6; USHORT RGB888:1; @@ -3262,23 +3262,23 @@ typedef struct _ATOM_MODE_MISC_INFO USHORT Interlace:1; USHORT DoubleClock:1; USHORT RGB888:1; - USHORT Reserved:6; + USHORT Reserved:6; #endif }ATOM_MODE_MISC_INFO; - + typedef union _ATOM_MODE_MISC_INFO_ACCESS -{ +{ ATOM_MODE_MISC_INFO sbfAccess; USHORT usAccess; }ATOM_MODE_MISC_INFO_ACCESS; - + #else - + typedef union _ATOM_MODE_MISC_INFO_ACCESS -{ +{ USHORT usAccess; }ATOM_MODE_MISC_INFO_ACCESS; - + #endif // usModeMiscInfo- @@ -3296,7 +3296,7 @@ typedef union _ATOM_MODE_MISC_INFO_ACCESS //usRefreshRate- #define ATOM_REFRESH_43 43 #define ATOM_REFRESH_47 47 -#define ATOM_REFRESH_56 56 +#define ATOM_REFRESH_56 56 #define ATOM_REFRESH_60 60 #define ATOM_REFRESH_65 65 #define ATOM_REFRESH_70 70 @@ -3315,29 +3315,29 @@ typedef union _ATOM_MODE_MISC_INFO_ACCESS // VESA_HSYNC_WIDTH = VESA_HSYNC_TIME = EDID_HSPW // VESA_BORDER = EDID_BORDER -/****************************************************************************/ +/****************************************************************************/ // Structure used in SetCRTC_UsingDTDTimingTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _SET_CRTC_USING_DTD_TIMING_PARAMETERS { USHORT usH_Size; USHORT usH_Blanking_Time; USHORT usV_Size; - USHORT usV_Blanking_Time; + USHORT usV_Blanking_Time; USHORT usH_SyncOffset; USHORT usH_SyncWidth; USHORT usV_SyncOffset; USHORT usV_SyncWidth; - ATOM_MODE_MISC_INFO_ACCESS susModeMiscInfo; + ATOM_MODE_MISC_INFO_ACCESS susModeMiscInfo; UCHAR ucH_Border; // From DFP EDID UCHAR ucV_Border; - UCHAR ucCRTC; // ATOM_CRTC1 or ATOM_CRTC2 + UCHAR ucCRTC; // ATOM_CRTC1 or ATOM_CRTC2 UCHAR ucPadding[3]; }SET_CRTC_USING_DTD_TIMING_PARAMETERS; -/****************************************************************************/ +/****************************************************************************/ // Structure used in SetCRTC_TimingTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _SET_CRTC_TIMING_PARAMETERS { USHORT usH_Total; // horizontal total @@ -3358,11 +3358,11 @@ typedef struct _SET_CRTC_TIMING_PARAMETERS }SET_CRTC_TIMING_PARAMETERS; #define SET_CRTC_TIMING_PARAMETERS_PS_ALLOCATION SET_CRTC_TIMING_PARAMETERS -/****************************************************************************/ +/****************************************************************************/ // Structure used in StandardVESA_TimingTable -// AnalogTV_InfoTable +// AnalogTV_InfoTable // ComponentVideoInfoTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_MODE_TIMING { USHORT usCRTC_H_Total; @@ -3390,7 +3390,7 @@ typedef struct _ATOM_DTD_FORMAT USHORT usHActive; USHORT usHBlanking_Time; USHORT usVActive; - USHORT usVBlanking_Time; + USHORT usVBlanking_Time; USHORT usHSyncOffset; USHORT usHSyncWidth; USHORT usVSyncOffset; @@ -3404,10 +3404,10 @@ typedef struct _ATOM_DTD_FORMAT UCHAR ucRefreshRate; }ATOM_DTD_FORMAT; -/****************************************************************************/ -// Structure used in LVDS_InfoTable +/****************************************************************************/ +// Structure used in LVDS_InfoTable // * Need a document to describe this table -/****************************************************************************/ +/****************************************************************************/ #define SUPPORTED_LCD_REFRESHRATE_30Hz 0x0004 #define SUPPORTED_LCD_REFRESHRATE_40Hz 0x0008 #define SUPPORTED_LCD_REFRESHRATE_50Hz 0x0010 @@ -3417,7 +3417,7 @@ typedef struct _ATOM_DTD_FORMAT //ucTableContentRevision=1 typedef struct _ATOM_LVDS_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_DTD_FORMAT sLCDTiming; USHORT usModePatchTableOffset; USHORT usSupportedRefreshRate; //Refer to panel info table in ATOMBIOS extension Spec. @@ -3437,7 +3437,7 @@ typedef struct _ATOM_LVDS_INFO //ucTableContentRevision=2 typedef struct _ATOM_LVDS_INFO_V12 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_DTD_FORMAT sLCDTiming; USHORT usExtInfoTableOffset; USHORT usSupportedRefreshRate; //Refer to panel info table in ATOMBIOS extension Spec. @@ -3453,15 +3453,15 @@ typedef struct _ATOM_LVDS_INFO_V12 UCHAR ucSS_Id; USHORT usLCDVenderID; USHORT usLCDProductID; - UCHAR ucLCDPanel_SpecialHandlingCap; + UCHAR ucLCDPanel_SpecialHandlingCap; UCHAR ucPanelInfoSize; // start from ATOM_DTD_FORMAT to end of panel info, include ExtInfoTable UCHAR ucReserved[2]; }ATOM_LVDS_INFO_V12; //Definitions for ucLCDPanel_SpecialHandlingCap: -//Once DAL sees this CAP is set, it will read EDID from LCD on its own instead of using sLCDTiming in ATOM_LVDS_INFO_V12. -//Other entries in ATOM_LVDS_INFO_V12 are still valid/useful to DAL +//Once DAL sees this CAP is set, it will read EDID from LCD on its own instead of using sLCDTiming in ATOM_LVDS_INFO_V12. +//Other entries in ATOM_LVDS_INFO_V12 are still valid/useful to DAL #define LCDPANEL_CAP_READ_EDID 0x1 //If a design supports DRR (dynamic refresh rate) on internal panels (LVDS or EDP), this cap is set in ucLCDPanel_SpecialHandlingCap together @@ -3486,21 +3486,21 @@ typedef struct _ATOM_LVDS_INFO_V12 #define PANEL_COLOR_BIT_DEPTH_MASK 0x70 -// Bit7:{=0:Random Dithering disabled;1 Random Dithering enabled} +// Bit7:{=0:Random Dithering disabled;1 Random Dithering enabled} #define PANEL_RANDOM_DITHER 0x80 #define PANEL_RANDOM_DITHER_MASK 0x80 -#define ATOM_LVDS_INFO_LAST ATOM_LVDS_INFO_V12 // no need to change this +#define ATOM_LVDS_INFO_LAST ATOM_LVDS_INFO_V12 // no need to change this -/****************************************************************************/ +/****************************************************************************/ // Structures used by LCD_InfoTable V1.3 Note: previous version was called ATOM_LVDS_INFO_V12 // ASIC Families: NI // ucTableFormatRevision=1 // ucTableContentRevision=3 -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_LCD_INFO_V13 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_DTD_FORMAT sLCDTiming; USHORT usExtInfoTableOffset; USHORT usSupportedRefreshRate; //Refer to panel info table in ATOMBIOS extension Spec. @@ -3509,18 +3509,18 @@ typedef struct _ATOM_LCD_INFO_V13 // Bit0: {=0:single, =1:dual}, // Bit1: {=0:LDI format for RGB888, =1 FPDI format for RGB888} // was {=0:666RGB, =1:888RGB}, // Bit3:2: {Grey level} - // Bit6:4 Color Bit Depth definition (see below definition in EDID V1.4 @BYTE 14h) - // Bit7 Reserved. was for ATOM_PANEL_MISC_API_ENABLED, still need it? + // Bit6:4 Color Bit Depth definition (see below definition in EDID V1.4 @BYTE 14h) + // Bit7 Reserved. was for ATOM_PANEL_MISC_API_ENABLED, still need it? UCHAR ucPanelDefaultRefreshRate; UCHAR ucPanelIdentification; UCHAR ucSS_Id; USHORT usLCDVenderID; USHORT usLCDProductID; - UCHAR ucLCDPanel_SpecialHandlingCap; // Reorganized in V13 + UCHAR ucLCDPanel_SpecialHandlingCap; // Reorganized in V13 // Bit0: Once DAL sees this CAP is set, it will read EDID from LCD on its own // Bit1: See LCDPANEL_CAP_DRR_SUPPORTED // Bit2: a quick reference whether an embadded panel (LCD1 ) is LVDS (0) or eDP (1) - // Bit7-3: Reserved + // Bit7-3: Reserved UCHAR ucPanelInfoSize; // start from ATOM_DTD_FORMAT to end of panel info, include ExtInfoTable USHORT usBacklightPWM; // Backlight PWM in Hz. New in _V13 @@ -3539,13 +3539,13 @@ typedef struct _ATOM_LCD_INFO_V13 UCHAR ucDPCD_MAX_LANE_COUNT; // dpcd 02h UCHAR ucDPCD_MAX_DOWNSPREAD; // dpcd 03h - USHORT usMaxPclkFreqInSingleLink; // Max PixelClock frequency in single link mode. + USHORT usMaxPclkFreqInSingleLink; // Max PixelClock frequency in single link mode. UCHAR uceDPToLVDSRxId; UCHAR ucLcdReservd; ULONG ulReserved[2]; -}ATOM_LCD_INFO_V13; +}ATOM_LCD_INFO_V13; -#define ATOM_LCD_INFO_LAST ATOM_LCD_INFO_V13 +#define ATOM_LCD_INFO_LAST ATOM_LCD_INFO_V13 //Definitions for ucLCD_Misc #define ATOM_PANEL_MISC_V13_DUAL 0x00000001 @@ -3566,11 +3566,11 @@ typedef struct _ATOM_LCD_INFO_V13 // 1 0 1 - 14 Bits per Primary Color // 1 1 0 - 16 Bits per Primary Color // 1 1 1 - Reserved - + //Definitions for ucLCDPanel_SpecialHandlingCap: -//Once DAL sees this CAP is set, it will read EDID from LCD on its own instead of using sLCDTiming in ATOM_LVDS_INFO_V12. -//Other entries in ATOM_LVDS_INFO_V12 are still valid/useful to DAL +//Once DAL sees this CAP is set, it will read EDID from LCD on its own instead of using sLCDTiming in ATOM_LVDS_INFO_V12. +//Other entries in ATOM_LVDS_INFO_V12 are still valid/useful to DAL #define LCDPANEL_CAP_V13_READ_EDID 0x1 // = LCDPANEL_CAP_READ_EDID no change comparing to previous version //If a design supports DRR (dynamic refresh rate) on internal panels (LVDS or EDP), this cap is set in ucLCDPanel_SpecialHandlingCap together @@ -3582,7 +3582,7 @@ typedef struct _ATOM_LCD_INFO_V13 #define LCDPANEL_CAP_V13_eDP 0x4 // = LCDPANEL_CAP_eDP no change comparing to previous version //uceDPToLVDSRxId -#define eDP_TO_LVDS_RX_DISABLE 0x00 // no eDP->LVDS translator chip +#define eDP_TO_LVDS_RX_DISABLE 0x00 // no eDP->LVDS translator chip #define eDP_TO_LVDS_COMMON_ID 0x01 // common eDP->LVDS translator chip without AMD SW init #define eDP_TO_LVDS_RT_ID 0x02 // RT tanslator which require AMD SW init @@ -3639,7 +3639,7 @@ typedef struct _ATOM_PANEL_RESOLUTION_PATCH_RECORD //ucTableContentRevision=2 typedef struct _ATOM_SPREAD_SPECTRUM_ASSIGNMENT { - USHORT usSpreadSpectrumPercentage; + USHORT usSpreadSpectrumPercentage; UCHAR ucSpreadSpectrumType; //Bit1=0 Down Spread,=1 Center Spread. Bit1=1 Ext. =0 Int. Bit2=1: PCIE REFCLK SS =0 iternal PPLL SS Others:TBD UCHAR ucSS_Step; UCHAR ucSS_Delay; @@ -3649,8 +3649,8 @@ typedef struct _ATOM_SPREAD_SPECTRUM_ASSIGNMENT }ATOM_SPREAD_SPECTRUM_ASSIGNMENT; #define ATOM_MAX_SS_ENTRY 16 -#define ATOM_DP_SS_ID1 0x0f1 // SS ID for internal DP stream at 2.7Ghz. if ATOM_DP_SS_ID2 does not exist in SS_InfoTable, it is used for internal DP stream at 1.62Ghz as well. -#define ATOM_DP_SS_ID2 0x0f2 // SS ID for internal DP stream at 1.62Ghz, if it exists in SS_InfoTable. +#define ATOM_DP_SS_ID1 0x0f1 // SS ID for internal DP stream at 2.7Ghz. if ATOM_DP_SS_ID2 does not exist in SS_InfoTable, it is used for internal DP stream at 1.62Ghz as well. +#define ATOM_DP_SS_ID2 0x0f2 // SS ID for internal DP stream at 1.62Ghz, if it exists in SS_InfoTable. #define ATOM_LVLINK_2700MHz_SS_ID 0x0f3 // SS ID for LV link translator chip at 2.7Ghz #define ATOM_LVLINK_1620MHz_SS_ID 0x0f4 // SS ID for LV link translator chip at 1.62Ghz @@ -3662,18 +3662,18 @@ typedef struct _ATOM_SPREAD_SPECTRUM_ASSIGNMENT #define ATOM_INTERNAL_SS_MASK 0x00000000 #define ATOM_EXTERNAL_SS_MASK 0x00000002 #define EXEC_SS_STEP_SIZE_SHIFT 2 -#define EXEC_SS_DELAY_SHIFT 4 +#define EXEC_SS_DELAY_SHIFT 4 #define ACTIVEDATA_TO_BLON_DELAY_SHIFT 4 typedef struct _ATOM_SPREAD_SPECTRUM_INFO -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; ATOM_SPREAD_SPECTRUM_ASSIGNMENT asSS_Info[ATOM_MAX_SS_ENTRY]; }ATOM_SPREAD_SPECTRUM_INFO; -/****************************************************************************/ +/****************************************************************************/ // Structure used in AnalogTV_InfoTable (Top level) -/****************************************************************************/ +/****************************************************************************/ //ucTVBootUpDefaultStd definition: //ATOM_TV_NTSC 1 @@ -3700,9 +3700,9 @@ typedef struct _ATOM_SPREAD_SPECTRUM_INFO typedef struct _ATOM_ANALOG_TV_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; UCHAR ucTV_SupportedStandard; - UCHAR ucTV_BootUpDefaultStandard; + UCHAR ucTV_BootUpDefaultStandard; UCHAR ucExt_TV_ASIC_ID; UCHAR ucExt_TV_ASIC_SlaveAddr; /*ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING];*/ @@ -3713,9 +3713,9 @@ typedef struct _ATOM_ANALOG_TV_INFO typedef struct _ATOM_ANALOG_TV_INFO_V1_2 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; UCHAR ucTV_SupportedStandard; - UCHAR ucTV_BootUpDefaultStandard; + UCHAR ucTV_BootUpDefaultStandard; UCHAR ucExt_TV_ASIC_ID; UCHAR ucExt_TV_ASIC_SlaveAddr; ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING_V1_2]; @@ -3723,9 +3723,9 @@ typedef struct _ATOM_ANALOG_TV_INFO_V1_2 typedef struct _ATOM_DPCD_INFO { - UCHAR ucRevisionNumber; //10h : Revision 1.0; 11h : Revision 1.1 + UCHAR ucRevisionNumber; //10h : Revision 1.0; 11h : Revision 1.1 UCHAR ucMaxLinkRate; //06h : 1.62Gbps per lane; 0Ah = 2.7Gbps per lane - UCHAR ucMaxLane; //Bits 4:0 = MAX_LANE_COUNT (1/2/4). Bit 7 = ENHANCED_FRAME_CAP + UCHAR ucMaxLane; //Bits 4:0 = MAX_LANE_COUNT (1/2/4). Bit 7 = ENHANCED_FRAME_CAP UCHAR ucMaxDownSpread; //Bit0 = 0: No Down spread; Bit0 = 1: 0.5% (Subject to change according to DP spec) }ATOM_DPCD_INFO; @@ -3738,7 +3738,7 @@ typedef struct _ATOM_DPCD_INFO // Current Mode timing and Dail Timing and/or STD timing data EACH device. They can be broken down as below. // All the addresses below are the offsets from the frame buffer start.They all MUST be Dword aligned! // To driver: The physical address of this memory portion=mmFB_START(4K aligned)+ATOMBIOS_VRAM_USAGE_START_ADDR+ATOM_x_ADDR -// To Bios: ATOMBIOS_VRAM_USAGE_START_ADDR+ATOM_x_ADDR->MM_INDEX +// To Bios: ATOMBIOS_VRAM_USAGE_START_ADDR+ATOM_x_ADDR->MM_INDEX #ifndef VESA_MEMORY_IN_64K_BLOCK #define VESA_MEMORY_IN_64K_BLOCK 0x100 //256*64K=16Mb (Max. VESA memory is 16Mb!) @@ -3748,11 +3748,11 @@ typedef struct _ATOM_DPCD_INFO #define ATOM_HWICON_SURFACE_SIZE 4096 //In Bytes #define ATOM_HWICON_INFOTABLE_SIZE 32 #define MAX_DTD_MODE_IN_VRAM 6 -#define ATOM_DTD_MODE_SUPPORT_TBL_SIZE (MAX_DTD_MODE_IN_VRAM*28) //28= (SIZEOF ATOM_DTD_FORMAT) +#define ATOM_DTD_MODE_SUPPORT_TBL_SIZE (MAX_DTD_MODE_IN_VRAM*28) //28= (SIZEOF ATOM_DTD_FORMAT) #define ATOM_STD_MODE_SUPPORT_TBL_SIZE 32*8 //32 is a predefined number,8= (SIZEOF ATOM_STD_FORMAT) //20 bytes for Encoder Type and DPCD in STD EDID area -#define DFP_ENCODER_TYPE_OFFSET (ATOM_EDID_RAW_DATASIZE + ATOM_DTD_MODE_SUPPORT_TBL_SIZE + ATOM_STD_MODE_SUPPORT_TBL_SIZE - 20) -#define ATOM_DP_DPCD_OFFSET (DFP_ENCODER_TYPE_OFFSET + 4 ) +#define DFP_ENCODER_TYPE_OFFSET (ATOM_EDID_RAW_DATASIZE + ATOM_DTD_MODE_SUPPORT_TBL_SIZE + ATOM_STD_MODE_SUPPORT_TBL_SIZE - 20) +#define ATOM_DP_DPCD_OFFSET (DFP_ENCODER_TYPE_OFFSET + 4 ) #define ATOM_HWICON1_SURFACE_ADDR 0 #define ATOM_HWICON2_SURFACE_ADDR (ATOM_HWICON1_SURFACE_ADDR + ATOM_HWICON_SURFACE_SIZE) @@ -3805,12 +3805,12 @@ typedef struct _ATOM_DPCD_INFO #define ATOM_DP_TRAINING_TBL_ADDR (ATOM_DFP5_STD_MODE_TBL_ADDR + ATOM_STD_MODE_SUPPORT_TBL_SIZE) -#define ATOM_STACK_STORAGE_START (ATOM_DP_TRAINING_TBL_ADDR + 1024) -#define ATOM_STACK_STORAGE_END ATOM_STACK_STORAGE_START + 512 +#define ATOM_STACK_STORAGE_START (ATOM_DP_TRAINING_TBL_ADDR + 1024) +#define ATOM_STACK_STORAGE_END ATOM_STACK_STORAGE_START + 512 //The size below is in Kb! #define ATOM_VRAM_RESERVE_SIZE ((((ATOM_STACK_STORAGE_END - ATOM_HWICON1_SURFACE_ADDR)>>10)+4)&0xFFFC) - + #define ATOM_VRAM_RESERVE_V2_SIZE 32 #define ATOM_VRAM_OPERATION_FLAGS_MASK 0xC0000000L @@ -3818,15 +3818,15 @@ typedef struct _ATOM_DPCD_INFO #define ATOM_VRAM_BLOCK_NEEDS_NO_RESERVATION 0x1 #define ATOM_VRAM_BLOCK_NEEDS_RESERVATION 0x0 -/***********************************************************************************/ +/***********************************************************************************/ // Structure used in VRAM_UsageByFirmwareTable // Note1: This table is filled by SetBiosReservationStartInFB in CoreCommSubs.asm -// at running time. -// note2: From RV770, the memory is more than 32bit addressable, so we will change +// at running time. +// note2: From RV770, the memory is more than 32bit addressable, so we will change // ucTableFormatRevision=1,ucTableContentRevision=4, the structure remains -// exactly same as 1.1 and 1.2 (1.3 is never in use), but ulStartAddrUsedByFirmware +// exactly same as 1.1 and 1.2 (1.3 is never in use), but ulStartAddrUsedByFirmware // (in offset to start of memory address) is KB aligned instead of byte aligend. -/***********************************************************************************/ +/***********************************************************************************/ // Note3: /* If we change usReserved to "usFBUsedbyDrvInKB", then to VBIOS this usFBUsedbyDrvInKB is a predefined, unchanged constant across VGA or non VGA adapter, for CAIL, The size of FB access area is known, only thing missing is the Offset of FB Access area, so we can have: @@ -3842,7 +3842,7 @@ else //Non VGA case CAIL needs to claim an reserved area defined by FBAccessAreaOffset and usFBUsedbyDrvInKB in non VGA case.*/ -/***********************************************************************************/ +/***********************************************************************************/ #define ATOM_MAX_FIRMWARE_VRAM_USAGE_INFO 1 typedef struct _ATOM_FIRMWARE_VRAM_RESERVE_INFO @@ -3854,7 +3854,7 @@ typedef struct _ATOM_FIRMWARE_VRAM_RESERVE_INFO typedef struct _ATOM_VRAM_USAGE_BY_FIRMWARE { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_FIRMWARE_VRAM_RESERVE_INFO asFirmwareVramReserveInfo[ATOM_MAX_FIRMWARE_VRAM_USAGE_INFO]; }ATOM_VRAM_USAGE_BY_FIRMWARE; @@ -3868,13 +3868,13 @@ typedef struct _ATOM_FIRMWARE_VRAM_RESERVE_INFO_V1_5 typedef struct _ATOM_VRAM_USAGE_BY_FIRMWARE_V1_5 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_FIRMWARE_VRAM_RESERVE_INFO_V1_5 asFirmwareVramReserveInfo[ATOM_MAX_FIRMWARE_VRAM_USAGE_INFO]; }ATOM_VRAM_USAGE_BY_FIRMWARE_V1_5; -/****************************************************************************/ +/****************************************************************************/ // Structure used in GPIO_Pin_LUTTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_GPIO_PIN_ASSIGNMENT { USHORT usGpioPin_AIndex; @@ -3896,9 +3896,9 @@ typedef struct _ATOM_GPIO_PIN_LUT ATOM_GPIO_PIN_ASSIGNMENT asGPIO_Pin[1]; }ATOM_GPIO_PIN_LUT; -/****************************************************************************/ -// Structure used in ComponentVideoInfoTable -/****************************************************************************/ +/****************************************************************************/ +// Structure used in ComponentVideoInfoTable +/****************************************************************************/ #define GPIO_PIN_ACTIVE_HIGH 0x1 #define MAX_SUPPORTED_CV_STANDARDS 5 @@ -3926,17 +3926,17 @@ typedef struct _ATOM_GPIO_INFO //Line 3 out put 5V. #define ATOM_CV_LINE3_ASPECTRATIO_16_9_GPIO_A 0x01 //represent gpio 3 state for 16:9 #define ATOM_CV_LINE3_ASPECTRATIO_16_9_GPIO_B 0x02 //represent gpio 4 state for 16:9 -#define ATOM_CV_LINE3_ASPECTRATIO_16_9_GPIO_SHIFT 0x0 +#define ATOM_CV_LINE3_ASPECTRATIO_16_9_GPIO_SHIFT 0x0 -//Line 3 out put 2.2V +//Line 3 out put 2.2V #define ATOM_CV_LINE3_ASPECTRATIO_4_3_LETBOX_GPIO_A 0x04 //represent gpio 3 state for 4:3 Letter box #define ATOM_CV_LINE3_ASPECTRATIO_4_3_LETBOX_GPIO_B 0x08 //represent gpio 4 state for 4:3 Letter box -#define ATOM_CV_LINE3_ASPECTRATIO_4_3_LETBOX_GPIO_SHIFT 0x2 +#define ATOM_CV_LINE3_ASPECTRATIO_4_3_LETBOX_GPIO_SHIFT 0x2 //Line 3 out put 0V #define ATOM_CV_LINE3_ASPECTRATIO_4_3_GPIO_A 0x10 //represent gpio 3 state for 4:3 #define ATOM_CV_LINE3_ASPECTRATIO_4_3_GPIO_B 0x20 //represent gpio 4 state for 4:3 -#define ATOM_CV_LINE3_ASPECTRATIO_4_3_GPIO_SHIFT 0x4 +#define ATOM_CV_LINE3_ASPECTRATIO_4_3_GPIO_SHIFT 0x4 #define ATOM_CV_LINE3_ASPECTRATIO_MASK 0x3F // bit [5:0] @@ -3988,11 +3988,11 @@ typedef struct _ATOM_COMPONENT_VIDEO_INFO_V21 #define ATOM_COMPONENT_VIDEO_INFO_LAST ATOM_COMPONENT_VIDEO_INFO_V21 -/****************************************************************************/ +/****************************************************************************/ // Structure used in object_InfoTable -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_OBJECT_HEADER -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; USHORT usDeviceSupport; USHORT usConnectorObjectTableOffset; @@ -4003,7 +4003,7 @@ typedef struct _ATOM_OBJECT_HEADER }ATOM_OBJECT_HEADER; typedef struct _ATOM_OBJECT_HEADER_V3 -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; USHORT usDeviceSupport; USHORT usConnectorObjectTableOffset; @@ -4016,20 +4016,20 @@ typedef struct _ATOM_OBJECT_HEADER_V3 typedef struct _ATOM_DISPLAY_OBJECT_PATH { - USHORT usDeviceTag; //supported device + USHORT usDeviceTag; //supported device USHORT usSize; //the size of ATOM_DISPLAY_OBJECT_PATH - USHORT usConnObjectId; //Connector Object ID - USHORT usGPUObjectId; //GPU ID + USHORT usConnObjectId; //Connector Object ID + USHORT usGPUObjectId; //GPU ID USHORT usGraphicObjIds[1]; //1st Encoder Obj source from GPU to last Graphic Obj destinate to connector. }ATOM_DISPLAY_OBJECT_PATH; typedef struct _ATOM_DISPLAY_EXTERNAL_OBJECT_PATH { - USHORT usDeviceTag; //supported device + USHORT usDeviceTag; //supported device USHORT usSize; //the size of ATOM_DISPLAY_OBJECT_PATH - USHORT usConnObjectId; //Connector Object ID - USHORT usGPUObjectId; //GPU ID - USHORT usGraphicObjIds[2]; //usGraphicObjIds[0]= GPU internal encoder, usGraphicObjIds[1]= external encoder + USHORT usConnObjectId; //Connector Object ID + USHORT usGPUObjectId; //GPU ID + USHORT usGraphicObjIds[2]; //usGraphicObjIds[0]= GPU internal encoder, usGraphicObjIds[1]= external encoder }ATOM_DISPLAY_EXTERNAL_OBJECT_PATH; typedef struct _ATOM_DISPLAY_OBJECT_PATH_TABLE @@ -4041,7 +4041,7 @@ typedef struct _ATOM_DISPLAY_OBJECT_PATH_TABLE }ATOM_DISPLAY_OBJECT_PATH_TABLE; -typedef struct _ATOM_OBJECT //each object has this structure +typedef struct _ATOM_OBJECT //each object has this structure { USHORT usObjectID; USHORT usSrcDstTableOffset; @@ -4049,7 +4049,7 @@ typedef struct _ATOM_OBJECT //each object has thi USHORT usReserved; }ATOM_OBJECT; -typedef struct _ATOM_OBJECT_TABLE //Above 4 object table offset pointing to a bunch of objects all have this structure +typedef struct _ATOM_OBJECT_TABLE //Above 4 object table offset pointing to a bunch of objects all have this structure { UCHAR ucNumberOfObjects; UCHAR ucPadding[3]; @@ -4088,7 +4088,7 @@ typedef struct _ATOM_SRC_DST_TABLE_FOR_ONE_OBJECT //usSrcDstTableOffset #define MAX_NUMBER_OF_EXT_AUXDDC_LUT_ENTRIES (EXT_AUXDDC_LUTINDEX_7+1) //ucChannelMapping are defined as following -//for DP connector, eDP, DP to VGA/LVDS +//for DP connector, eDP, DP to VGA/LVDS //Bit[1:0]: Define which pin connect to DP connector DP_Lane0, =0: source from GPU pin TX0, =1: from GPU pin TX1, =2: from GPU pin TX2, =3 from GPU pin TX3 //Bit[3:2]: Define which pin connect to DP connector DP_Lane1, =0: source from GPU pin TX0, =1: from GPU pin TX1, =2: from GPU pin TX2, =3 from GPU pin TX3 //Bit[5:4]: Define which pin connect to DP connector DP_Lane2, =0: source from GPU pin TX0, =1: from GPU pin TX1, =2: from GPU pin TX2, =3 from GPU pin TX3 @@ -4108,7 +4108,7 @@ typedef struct _ATOM_DP_CONN_CHANNEL_MAPPING #endif }ATOM_DP_CONN_CHANNEL_MAPPING; -//for DVI/HDMI, in dual link case, both links have to have same mapping. +//for DVI/HDMI, in dual link case, both links have to have same mapping. //Bit[1:0]: Define which pin connect to DVI connector data Lane2, =0: source from GPU pin TX0, =1: from GPU pin TX1, =2: from GPU pin TX2, =3 from GPU pin TX3 //Bit[3:2]: Define which pin connect to DVI connector data Lane1, =0: source from GPU pin TX0, =1: from GPU pin TX1, =2: from GPU pin TX2, =3 from GPU pin TX3 //Bit[5:4]: Define which pin connect to DVI connector data Lane0, =0: source from GPU pin TX0, =1: from GPU pin TX1, =2: from GPU pin TX2, =3 from GPU pin TX3 @@ -4130,8 +4130,8 @@ typedef struct _ATOM_DVI_CONN_CHANNEL_MAPPING typedef struct _EXT_DISPLAY_PATH { - USHORT usDeviceTag; //A bit vector to show what devices are supported - USHORT usDeviceACPIEnum; //16bit device ACPI id. + USHORT usDeviceTag; //A bit vector to show what devices are supported + USHORT usDeviceACPIEnum; //16bit device ACPI id. USHORT usDeviceConnector; //A physical connector for displays to plug in, using object connector definitions UCHAR ucExtAUXDDCLutIndex; //An index into external AUX/DDC channel LUT UCHAR ucExtHPDPINLutIndex; //An index into external HPD pin LUT @@ -4143,9 +4143,9 @@ typedef struct _EXT_DISPLAY_PATH }; UCHAR ucChPNInvert; // bit vector for up to 8 lanes, =0: P and N is not invert, =1 P and N is inverted USHORT usCaps; - USHORT usReserved; + USHORT usReserved; }EXT_DISPLAY_PATH; - + #define NUMBER_OF_UCHAR_FOR_GUID 16 #define MAX_NUMBER_OF_EXT_DISPLAY_PATH 7 @@ -4158,7 +4158,7 @@ typedef struct _ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO ATOM_COMMON_TABLE_HEADER sHeader; UCHAR ucGuid [NUMBER_OF_UCHAR_FOR_GUID]; // a GUID is a 16 byte long string EXT_DISPLAY_PATH sPath[MAX_NUMBER_OF_EXT_DISPLAY_PATH]; // total of fixed 7 entries. - UCHAR ucChecksum; // a simple Checksum of the sum of whole structure equal to 0x0. + UCHAR ucChecksum; // a simple Checksum of the sum of whole structure equal to 0x0. UCHAR uc3DStereoPinId; // use for eDP panel UCHAR ucRemoteDisplayConfig; UCHAR uceDPToLVDSRxId; @@ -4174,7 +4174,7 @@ typedef struct _ATOM_COMMON_RECORD_HEADER }ATOM_COMMON_RECORD_HEADER; -#define ATOM_I2C_RECORD_TYPE 1 +#define ATOM_I2C_RECORD_TYPE 1 #define ATOM_HPD_INT_RECORD_TYPE 2 #define ATOM_OUTPUT_PROTECTION_RECORD_TYPE 3 #define ATOM_CONNECTOR_DEVICE_TAG_RECORD_TYPE 4 @@ -4202,19 +4202,19 @@ typedef struct _ATOM_COMMON_RECORD_HEADER typedef struct _ATOM_I2C_RECORD { ATOM_COMMON_RECORD_HEADER sheader; - ATOM_I2C_ID_CONFIG sucI2cId; + ATOM_I2C_ID_CONFIG sucI2cId; UCHAR ucI2CAddr; //The slave address, it's 0 when the record is attached to connector for DDC }ATOM_I2C_RECORD; typedef struct _ATOM_HPD_INT_RECORD { ATOM_COMMON_RECORD_HEADER sheader; - UCHAR ucHPDIntGPIOID; //Corresponding block in GPIO_PIN_INFO table gives the pin info + UCHAR ucHPDIntGPIOID; //Corresponding block in GPIO_PIN_INFO table gives the pin info UCHAR ucPlugged_PinState; }ATOM_HPD_INT_RECORD; -typedef struct _ATOM_OUTPUT_PROTECTION_RECORD +typedef struct _ATOM_OUTPUT_PROTECTION_RECORD { ATOM_COMMON_RECORD_HEADER sheader; UCHAR ucProtectionFlag; @@ -4262,7 +4262,7 @@ typedef struct _ATOM_ENCODER_FPGA_CONTROL_RECORD typedef struct _ATOM_CONNECTOR_CVTV_SHARE_DIN_RECORD { ATOM_COMMON_RECORD_HEADER sheader; - UCHAR ucGPIOID; //Corresponding block in GPIO_PIN_INFO table gives the pin info + UCHAR ucGPIOID; //Corresponding block in GPIO_PIN_INFO table gives the pin info UCHAR ucTVActiveState; //Indicating when the pin==0 or 1 when TV is connected }ATOM_CONNECTOR_CVTV_SHARE_DIN_RECORD; @@ -4296,18 +4296,18 @@ typedef struct _ATOM_OBJECT_GPIO_CNTL_RECORD ATOM_GPIO_PIN_CONTROL_PAIR asGpio[1]; // the real gpio pin pair determined by number of pins ucNumberOfPins }ATOM_OBJECT_GPIO_CNTL_RECORD; -//Definitions for GPIO pin state +//Definitions for GPIO pin state #define GPIO_PIN_TYPE_INPUT 0x00 #define GPIO_PIN_TYPE_OUTPUT 0x10 #define GPIO_PIN_TYPE_HW_CONTROL 0x20 -//For GPIO_PIN_TYPE_OUTPUT the following is defined +//For GPIO_PIN_TYPE_OUTPUT the following is defined #define GPIO_PIN_OUTPUT_STATE_MASK 0x01 #define GPIO_PIN_OUTPUT_STATE_SHIFT 0 #define GPIO_PIN_STATE_ACTIVE_LOW 0x0 #define GPIO_PIN_STATE_ACTIVE_HIGH 0x1 -// Indexes to GPIO array in GLSync record +// Indexes to GPIO array in GLSync record // GLSync record is for Frame Lock/Gen Lock feature. #define ATOM_GPIO_INDEX_GLSYNC_REFCLK 0 #define ATOM_GPIO_INDEX_GLSYNC_HSYNC 1 @@ -4329,26 +4329,26 @@ typedef struct _ATOM_ENCODER_DVO_CF_RECORD // Bit maps for ATOM_ENCODER_CAP_RECORD.ucEncoderCap #define ATOM_ENCODER_CAP_RECORD_HBR2 0x01 // DP1.2 HBR2 is supported by HW encoder -#define ATOM_ENCODER_CAP_RECORD_HBR2_EN 0x02 // DP1.2 HBR2 setting is qualified and HBR2 can be enabled +#define ATOM_ENCODER_CAP_RECORD_HBR2_EN 0x02 // DP1.2 HBR2 setting is qualified and HBR2 can be enabled typedef struct _ATOM_ENCODER_CAP_RECORD { ATOM_COMMON_RECORD_HEADER sheader; union { - USHORT usEncoderCap; + USHORT usEncoderCap; struct { #if ATOM_BIG_ENDIAN USHORT usReserved:14; // Bit1-15 may be defined for other capability in future USHORT usHBR2En:1; // Bit1 is for DP1.2 HBR2 enable - USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability. + USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability. #else - USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability. + USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability. USHORT usHBR2En:1; // Bit1 is for DP1.2 HBR2 enable USHORT usReserved:14; // Bit1-15 may be defined for other capability in future #endif }; - }; -}ATOM_ENCODER_CAP_RECORD; + }; +}ATOM_ENCODER_CAP_RECORD; // value for ATOM_CONNECTOR_CF_RECORD.ucConnectedDvoBundle #define ATOM_CONNECTOR_CF_RECORD_CONNECTED_UPPER12BITBUNDLEA 1 @@ -4380,7 +4380,7 @@ typedef struct _ATOM_CONNECTOR_PCIE_SUBCONNECTOR_RECORD typedef struct _ATOM_ROUTER_DDC_PATH_SELECT_RECORD { - ATOM_COMMON_RECORD_HEADER sheader; + ATOM_COMMON_RECORD_HEADER sheader; UCHAR ucMuxType; //decide the number of ucMuxState, =0, no pin state, =1: single state with complement, >1: multiple state UCHAR ucMuxControlPin; UCHAR ucMuxState[2]; //for alligment purpose @@ -4388,7 +4388,7 @@ typedef struct _ATOM_ROUTER_DDC_PATH_SELECT_RECORD typedef struct _ATOM_ROUTER_DATA_CLOCK_PATH_SELECT_RECORD { - ATOM_COMMON_RECORD_HEADER sheader; + ATOM_COMMON_RECORD_HEADER sheader; UCHAR ucMuxType; UCHAR ucMuxControlPin; UCHAR ucMuxState[2]; //for alligment purpose @@ -4401,7 +4401,7 @@ typedef struct _ATOM_ROUTER_DATA_CLOCK_PATH_SELECT_RECORD typedef struct _ATOM_CONNECTOR_HPDPIN_LUT_RECORD //record for ATOM_CONNECTOR_HPDPIN_LUT_RECORD_TYPE { ATOM_COMMON_RECORD_HEADER sheader; - UCHAR ucHPDPINMap[MAX_NUMBER_OF_EXT_HPDPIN_LUT_ENTRIES]; //An fixed size array which maps external pins to internal GPIO_PIN_INFO table + UCHAR ucHPDPINMap[MAX_NUMBER_OF_EXT_HPDPIN_LUT_ENTRIES]; //An fixed size array which maps external pins to internal GPIO_PIN_INFO table }ATOM_CONNECTOR_HPDPIN_LUT_RECORD; typedef struct _ATOM_CONNECTOR_AUXDDC_LUT_RECORD //record for ATOM_CONNECTOR_AUXDDC_LUT_RECORD_TYPE @@ -4447,9 +4447,9 @@ typedef struct _ATOM_BRACKET_LAYOUT_RECORD ATOM_CONNECTOR_LAYOUT_INFO asConnInfo[1]; }ATOM_BRACKET_LAYOUT_RECORD; -/****************************************************************************/ +/****************************************************************************/ // ASIC voltage data table -/****************************************************************************/ +/****************************************************************************/ typedef struct _ATOM_VOLTAGE_INFO_HEADER { USHORT usVDDCBaseLevel; //In number of 50mv unit @@ -4465,7 +4465,7 @@ typedef struct _ATOM_VOLTAGE_INFO_HEADER typedef struct _ATOM_VOLTAGE_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_VOLTAGE_INFO_HEADER viHeader; UCHAR ucVoltageEntries[64]; //64 is for allocation, the actual number of entry is present at ucNumOfVoltageEntries*ucBytesPerVoltageEntry }ATOM_VOLTAGE_INFO; @@ -4497,10 +4497,10 @@ typedef struct _ATOM_VOLTAGE_FORMULA_V2 typedef struct _ATOM_VOLTAGE_CONTROL { - UCHAR ucVoltageControlId; //Indicate it is controlled by I2C or GPIO or HW state machine + UCHAR ucVoltageControlId; //Indicate it is controlled by I2C or GPIO or HW state machine UCHAR ucVoltageControlI2cLine; UCHAR ucVoltageControlAddress; - UCHAR ucVoltageControlOffset; + UCHAR ucVoltageControlOffset; USHORT usGpioPin_AIndex; //GPIO_PAD register index UCHAR ucGpioPinBitShift[9]; //at most 8 pin support 255 VIDs, termintate with 0xff UCHAR ucReserved; @@ -4513,11 +4513,11 @@ typedef struct _ATOM_VOLTAGE_CONTROL #define VOLTAGE_CONTROL_ID_LM64 0x01 //I2C control, used for R5xx Core Voltage #define VOLTAGE_CONTROL_ID_DAC 0x02 //I2C control, used for R5xx/R6xx MVDDC,MVDDQ or VDDCI #define VOLTAGE_CONTROL_ID_VT116xM 0x03 //I2C control, used for R6xx Core Voltage -#define VOLTAGE_CONTROL_ID_DS4402 0x04 -#define VOLTAGE_CONTROL_ID_UP6266 0x05 +#define VOLTAGE_CONTROL_ID_DS4402 0x04 +#define VOLTAGE_CONTROL_ID_UP6266 0x05 #define VOLTAGE_CONTROL_ID_SCORPIO 0x06 -#define VOLTAGE_CONTROL_ID_VT1556M 0x07 -#define VOLTAGE_CONTROL_ID_CHL822x 0x08 +#define VOLTAGE_CONTROL_ID_VT1556M 0x07 +#define VOLTAGE_CONTROL_ID_CHL822x 0x08 #define VOLTAGE_CONTROL_ID_VT1586M 0x09 #define VOLTAGE_CONTROL_ID_UP1637 0x0A #define VOLTAGE_CONTROL_ID_CHL8214 0x0B @@ -4530,30 +4530,30 @@ typedef struct _ATOM_VOLTAGE_CONTROL typedef struct _ATOM_VOLTAGE_OBJECT { - UCHAR ucVoltageType; //Indicate Voltage Source: VDDC, MVDDC, MVDDQ or MVDDCI - UCHAR ucSize; //Size of Object - ATOM_VOLTAGE_CONTROL asControl; //describ how to control - ATOM_VOLTAGE_FORMULA asFormula; //Indicate How to convert real Voltage to VID + UCHAR ucVoltageType; //Indicate Voltage Source: VDDC, MVDDC, MVDDQ or MVDDCI + UCHAR ucSize; //Size of Object + ATOM_VOLTAGE_CONTROL asControl; //describ how to control + ATOM_VOLTAGE_FORMULA asFormula; //Indicate How to convert real Voltage to VID }ATOM_VOLTAGE_OBJECT; typedef struct _ATOM_VOLTAGE_OBJECT_V2 { - UCHAR ucVoltageType; //Indicate Voltage Source: VDDC, MVDDC, MVDDQ or MVDDCI - UCHAR ucSize; //Size of Object - ATOM_VOLTAGE_CONTROL asControl; //describ how to control - ATOM_VOLTAGE_FORMULA_V2 asFormula; //Indicate How to convert real Voltage to VID + UCHAR ucVoltageType; //Indicate Voltage Source: VDDC, MVDDC, MVDDQ or MVDDCI + UCHAR ucSize; //Size of Object + ATOM_VOLTAGE_CONTROL asControl; //describ how to control + ATOM_VOLTAGE_FORMULA_V2 asFormula; //Indicate How to convert real Voltage to VID }ATOM_VOLTAGE_OBJECT_V2; typedef struct _ATOM_VOLTAGE_OBJECT_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; - ATOM_VOLTAGE_OBJECT asVoltageObj[3]; //Info for Voltage control + ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_VOLTAGE_OBJECT asVoltageObj[3]; //Info for Voltage control }ATOM_VOLTAGE_OBJECT_INFO; typedef struct _ATOM_VOLTAGE_OBJECT_INFO_V2 { - ATOM_COMMON_TABLE_HEADER sHeader; - ATOM_VOLTAGE_OBJECT_V2 asVoltageObj[3]; //Info for Voltage control + ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_VOLTAGE_OBJECT_V2 asVoltageObj[3]; //Info for Voltage control }ATOM_VOLTAGE_OBJECT_INFO_V2; typedef struct _ATOM_LEAKID_VOLTAGE @@ -4564,9 +4564,9 @@ typedef struct _ATOM_LEAKID_VOLTAGE }ATOM_LEAKID_VOLTAGE; typedef struct _ATOM_VOLTAGE_OBJECT_HEADER_V3{ - UCHAR ucVoltageType; //Indicate Voltage Source: VDDC, MVDDC, MVDDQ or MVDDCI - UCHAR ucVoltageMode; //Indicate voltage control mode: Init/Set/Leakage/Set phase - USHORT usSize; //Size of Object + UCHAR ucVoltageType; //Indicate Voltage Source: VDDC, MVDDC, MVDDQ or MVDDCI + UCHAR ucVoltageMode; //Indicate voltage control mode: Init/Set/Leakage/Set phase + USHORT usSize; //Size of Object }ATOM_VOLTAGE_OBJECT_HEADER_V3; // ATOM_VOLTAGE_OBJECT_HEADER_V3.ucVoltageMode @@ -4574,7 +4574,7 @@ typedef struct _ATOM_VOLTAGE_OBJECT_HEADER_V3{ #define VOLTAGE_OBJ_VR_I2C_INIT_SEQ 3 //VOLTAGE REGULATOR INIT sequece through I2C -> ATOM_I2C_VOLTAGE_OBJECT_V3 #define VOLTAGE_OBJ_PHASE_LUT 4 //Set Vregulator Phase lookup table ->ATOM_GPIO_VOLTAGE_OBJECT_V3 #define VOLTAGE_OBJ_SVID2 7 //Indicate voltage control by SVID2 ->ATOM_SVID2_VOLTAGE_OBJECT_V3 -#define VOLTAGE_OBJ_EVV 8 +#define VOLTAGE_OBJ_EVV 8 #define VOLTAGE_OBJ_PWRBOOST_LEAKAGE_LUT 0x10 //Powerboost Voltage and LeakageId lookup table->ATOM_LEAKAGE_VOLTAGE_OBJECT_V3 #define VOLTAGE_OBJ_HIGH_STATE_LEAKAGE_LUT 0x11 //High voltage state Voltage and LeakageId lookup table->ATOM_LEAKAGE_VOLTAGE_OBJECT_V3 #define VOLTAGE_OBJ_HIGH1_STATE_LEAKAGE_LUT 0x12 //High1 voltage state Voltage and LeakageId lookup table->ATOM_LEAKAGE_VOLTAGE_OBJECT_V3 @@ -4588,7 +4588,7 @@ typedef struct _VOLTAGE_LUT_ENTRY_V2 typedef struct _LEAKAGE_VOLTAGE_LUT_ENTRY_V2 { USHORT usVoltageLevel; // The Voltage ID which is used to program GPIO register - USHORT usVoltageId; + USHORT usVoltageId; USHORT usLeakageId; // The corresponding Voltage Value, in mV }LEAKAGE_VOLTAGE_LUT_ENTRY_V2; @@ -4598,7 +4598,7 @@ typedef struct _ATOM_I2C_VOLTAGE_OBJECT_V3 UCHAR ucVoltageRegulatorId; //Indicate Voltage Regulator Id UCHAR ucVoltageControlI2cLine; UCHAR ucVoltageControlAddress; - UCHAR ucVoltageControlOffset; + UCHAR ucVoltageControlOffset; ULONG ulReserved; VOLTAGE_LUT_ENTRY asVolI2cLut[1]; // end with 0xff }ATOM_I2C_VOLTAGE_OBJECT_V3; @@ -4610,12 +4610,12 @@ typedef struct _ATOM_I2C_VOLTAGE_OBJECT_V3 typedef struct _ATOM_GPIO_VOLTAGE_OBJECT_V3 { ATOM_VOLTAGE_OBJECT_HEADER_V3 sHeader; // voltage mode = VOLTAGE_OBJ_GPIO_LUT or VOLTAGE_OBJ_PHASE_LUT - UCHAR ucVoltageGpioCntlId; // default is 0 which indicate control through CG VID mode + UCHAR ucVoltageGpioCntlId; // default is 0 which indicate control through CG VID mode UCHAR ucGpioEntryNum; // indiate the entry numbers of Votlage/Gpio value Look up table UCHAR ucPhaseDelay; // phase delay in unit of micro second - UCHAR ucReserved; + UCHAR ucReserved; ULONG ulGpioMaskVal; // GPIO Mask value - VOLTAGE_LUT_ENTRY_V2 asVolGpioLut[1]; + VOLTAGE_LUT_ENTRY_V2 asVolGpioLut[1]; }ATOM_GPIO_VOLTAGE_OBJECT_V3; typedef struct _ATOM_LEAKAGE_VOLTAGE_OBJECT_V3 @@ -4623,9 +4623,9 @@ typedef struct _ATOM_LEAKAGE_VOLTAGE_OBJECT_V3 ATOM_VOLTAGE_OBJECT_HEADER_V3 sHeader; // voltage mode = 0x10/0x11/0x12 UCHAR ucLeakageCntlId; // default is 0 UCHAR ucLeakageEntryNum; // indicate the entry number of LeakageId/Voltage Lut table - UCHAR ucReserved[2]; + UCHAR ucReserved[2]; ULONG ulMaxVoltageLevel; - LEAKAGE_VOLTAGE_LUT_ENTRY_V2 asLeakageIdLut[1]; + LEAKAGE_VOLTAGE_LUT_ENTRY_V2 asLeakageIdLut[1]; }ATOM_LEAKAGE_VOLTAGE_OBJECT_V3; @@ -4635,9 +4635,9 @@ typedef struct _ATOM_SVID2_VOLTAGE_OBJECT_V3 // 14:7 – PSI0_VID // 6 – PSI0_EN // 5 – PSI1 -// 4:2 – load line slope trim. -// 1:0 – offset trim, - USHORT usLoadLine_PSI; +// 4:2 – load line slope trim. +// 1:0 – offset trim, + USHORT usLoadLine_PSI; // GPU GPIO pin Id to SVID2 regulator VRHot pin. possible value 0~31. 0 means GPIO0, 31 means GPIO31 UCHAR ucSVDGpioId; //0~31 indicate GPIO0~31 UCHAR ucSVCGpioId; //0~31 indicate GPIO0~31 @@ -4653,8 +4653,8 @@ typedef union _ATOM_VOLTAGE_OBJECT_V3{ typedef struct _ATOM_VOLTAGE_OBJECT_INFO_V3_1 { - ATOM_COMMON_TABLE_HEADER sHeader; - ATOM_VOLTAGE_OBJECT_V3 asVoltageObj[3]; //Info for Voltage control + ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_VOLTAGE_OBJECT_V3 asVoltageObj[3]; //Info for Voltage control }ATOM_VOLTAGE_OBJECT_INFO_V3_1; typedef struct _ATOM_ASIC_PROFILE_VOLTAGE @@ -4663,28 +4663,28 @@ typedef struct _ATOM_ASIC_PROFILE_VOLTAGE UCHAR ucReserved; USHORT usSize; USHORT usEfuseSpareStartAddr; - USHORT usFuseIndex[8]; //from LSB to MSB, Max 8bit,end of 0xffff if less than 8 efuse id, + USHORT usFuseIndex[8]; //from LSB to MSB, Max 8bit,end of 0xffff if less than 8 efuse id, ATOM_LEAKID_VOLTAGE asLeakVol[2]; //Leakid and relatd voltage }ATOM_ASIC_PROFILE_VOLTAGE; //ucProfileId -#define ATOM_ASIC_PROFILE_ID_EFUSE_VOLTAGE 1 +#define ATOM_ASIC_PROFILE_ID_EFUSE_VOLTAGE 1 #define ATOM_ASIC_PROFILE_ID_EFUSE_PERFORMANCE_VOLTAGE 1 #define ATOM_ASIC_PROFILE_ID_EFUSE_THERMAL_VOLTAGE 2 typedef struct _ATOM_ASIC_PROFILING_INFO { - ATOM_COMMON_TABLE_HEADER asHeader; + ATOM_COMMON_TABLE_HEADER asHeader; ATOM_ASIC_PROFILE_VOLTAGE asVoltage; }ATOM_ASIC_PROFILING_INFO; typedef struct _ATOM_ASIC_PROFILING_INFO_V2_1 { - ATOM_COMMON_TABLE_HEADER asHeader; + ATOM_COMMON_TABLE_HEADER asHeader; UCHAR ucLeakageBinNum; // indicate the entry number of LeakageId/Voltage Lut table - USHORT usLeakageBinArrayOffset; // offset of USHORT Leakage Bin list array ( from lower LeakageId to higher) + USHORT usLeakageBinArrayOffset; // offset of USHORT Leakage Bin list array ( from lower LeakageId to higher) - UCHAR ucElbVDDC_Num; + UCHAR ucElbVDDC_Num; USHORT usElbVDDC_IdArrayOffset; // offset of USHORT virtual VDDC voltage id ( 0xff01~0xff08 ) USHORT usElbVDDC_LevelArrayOffset; // offset of 2 dimension voltage level USHORT array @@ -4695,7 +4695,7 @@ typedef struct _ATOM_ASIC_PROFILING_INFO_V2_1 typedef struct _ATOM_ASIC_PROFILING_INFO_V3_1 { - ATOM_COMMON_TABLE_HEADER asHeader; + ATOM_COMMON_TABLE_HEADER asHeader; ULONG ulEvvDerateTdp; ULONG ulEvvDerateTdc; ULONG ulBoardCoreTemp; @@ -4745,7 +4745,7 @@ typedef struct _ATOM_POWER_SOURCE_OBJECT UCHAR ucPwrSensRegIndex; // I2C register Index if I2C detect UCHAR ucPwrSensRegBitMask; // detect which bit is used if I2C detect UCHAR ucPwrSensActiveState; // high active or low active - UCHAR ucReserve[3]; // reserve + UCHAR ucReserve[3]; // reserve USHORT usSensPwr; // in unit of watt }ATOM_POWER_SOURCE_OBJECT; @@ -4771,15 +4771,15 @@ typedef struct _ATOM_POWER_SOURCE_INFO typedef struct _ATOM_CLK_VOLT_CAPABILITY { - ULONG ulVoltageIndex; // The Voltage Index indicated by FUSE, same voltage index shared with SCLK DPM fuse table + ULONG ulVoltageIndex; // The Voltage Index indicated by FUSE, same voltage index shared with SCLK DPM fuse table ULONG ulMaximumSupportedCLK; // Maximum clock supported with specified voltage index, unit in 10kHz }ATOM_CLK_VOLT_CAPABILITY; typedef struct _ATOM_AVAILABLE_SCLK_LIST { ULONG ulSupportedSCLK; // Maximum clock supported with specified voltage index, unit in 10kHz - USHORT usVoltageIndex; // The Voltage Index indicated by FUSE for specified SCLK - USHORT usVoltageID; // The Voltage ID indicated by FUSE for specified SCLK + USHORT usVoltageIndex; // The Voltage Index indicated by FUSE for specified SCLK + USHORT usVoltageID; // The Voltage ID indicated by FUSE for specified SCLK }ATOM_AVAILABLE_SCLK_LIST; // ATOM_INTEGRATED_SYSTEM_INFO_V6 ulSystemConfig cap definition @@ -4790,28 +4790,28 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V6 { ATOM_COMMON_TABLE_HEADER sHeader; ULONG ulBootUpEngineClock; - ULONG ulDentistVCOFreq; - ULONG ulBootUpUMAClock; - ATOM_CLK_VOLT_CAPABILITY sDISPCLK_Voltage[4]; + ULONG ulDentistVCOFreq; + ULONG ulBootUpUMAClock; + ATOM_CLK_VOLT_CAPABILITY sDISPCLK_Voltage[4]; ULONG ulBootUpReqDisplayVector; ULONG ulOtherDisplayMisc; ULONG ulGPUCapInfo; ULONG ulSB_MMIO_Base_Addr; USHORT usRequestedPWMFreqInHz; - UCHAR ucHtcTmpLmt; + UCHAR ucHtcTmpLmt; UCHAR ucHtcHystLmt; - ULONG ulMinEngineClock; - ULONG ulSystemConfig; - ULONG ulCPUCapInfo; - USHORT usNBP0Voltage; + ULONG ulMinEngineClock; + ULONG ulSystemConfig; + ULONG ulCPUCapInfo; + USHORT usNBP0Voltage; USHORT usNBP1Voltage; - USHORT usBootUpNBVoltage; + USHORT usBootUpNBVoltage; USHORT usExtDispConnInfoOffset; - USHORT usPanelRefreshRateRange; - UCHAR ucMemoryType; + USHORT usPanelRefreshRateRange; + UCHAR ucMemoryType; UCHAR ucUMAChannelNumber; - ULONG ulCSR_M3_ARB_CNTL_DEFAULT[10]; - ULONG ulCSR_M3_ARB_CNTL_UVD[10]; + ULONG ulCSR_M3_ARB_CNTL_DEFAULT[10]; + ULONG ulCSR_M3_ARB_CNTL_UVD[10]; ULONG ulCSR_M3_ARB_CNTL_FS3D[10]; ATOM_AVAILABLE_SCLK_LIST sAvail_SCLK[5]; ULONG ulGMCRestoreResetTime; @@ -4829,24 +4829,24 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V6 USHORT usDVISSpreadRateIn10Hz; ULONG SclkDpmBoostMargin; ULONG SclkDpmThrottleMargin; - USHORT SclkDpmTdpLimitPG; + USHORT SclkDpmTdpLimitPG; USHORT SclkDpmTdpLimitBoost; ULONG ulBoostEngineCLock; - UCHAR ulBoostVid_2bit; + UCHAR ulBoostVid_2bit; UCHAR EnableBoost; USHORT GnbTdpLimit; USHORT usMaxLVDSPclkFreqInSingleLink; UCHAR ucLvdsMisc; UCHAR ucLVDSReserved; - ULONG ulReserved3[15]; - ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO sExtDispConnInfo; -}ATOM_INTEGRATED_SYSTEM_INFO_V6; + ULONG ulReserved3[15]; + ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO sExtDispConnInfo; +}ATOM_INTEGRATED_SYSTEM_INFO_V6; // ulGPUCapInfo #define INTEGRATED_SYSTEM_INFO_V6_GPUCAPINFO__TMDSHDMI_COHERENT_SINGLEPLL_MODE 0x01 #define INTEGRATED_SYSTEM_INFO_V6_GPUCAPINFO__DISABLE_AUX_HW_MODE_DETECTION 0x08 -//ucLVDSMisc: +//ucLVDSMisc: #define SYS_INFO_LVDSMISC__888_FPDI_MODE 0x01 #define SYS_INFO_LVDSMISC__DL_CH_SWAP 0x02 #define SYS_INFO_LVDSMISC__888_BPC 0x04 @@ -4862,57 +4862,57 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V6 /********************************************************************************************************************** ATOM_INTEGRATED_SYSTEM_INFO_V6 Description ulBootUpEngineClock: VBIOS bootup Engine clock frequency, in 10kHz unit. if it is equal 0, then VBIOS use pre-defined bootup engine clock -ulDentistVCOFreq: Dentist VCO clock in 10kHz unit. -ulBootUpUMAClock: System memory boot up clock frequency in 10Khz unit. +ulDentistVCOFreq: Dentist VCO clock in 10kHz unit. +ulBootUpUMAClock: System memory boot up clock frequency in 10Khz unit. sDISPCLK_Voltage: Report Display clock voltage requirement. ulBootUpReqDisplayVector: VBIOS boot up display IDs, following are supported devices in Liano/Ontaio projects: ATOM_DEVICE_CRT1_SUPPORT 0x0001 ATOM_DEVICE_CRT2_SUPPORT 0x0010 - ATOM_DEVICE_DFP1_SUPPORT 0x0008 - ATOM_DEVICE_DFP6_SUPPORT 0x0040 - ATOM_DEVICE_DFP2_SUPPORT 0x0080 - ATOM_DEVICE_DFP3_SUPPORT 0x0200 - ATOM_DEVICE_DFP4_SUPPORT 0x0400 + ATOM_DEVICE_DFP1_SUPPORT 0x0008 + ATOM_DEVICE_DFP6_SUPPORT 0x0040 + ATOM_DEVICE_DFP2_SUPPORT 0x0080 + ATOM_DEVICE_DFP3_SUPPORT 0x0200 + ATOM_DEVICE_DFP4_SUPPORT 0x0400 ATOM_DEVICE_DFP5_SUPPORT 0x0800 ATOM_DEVICE_LCD1_SUPPORT 0x0002 -ulOtherDisplayMisc: Other display related flags, not defined yet. +ulOtherDisplayMisc: Other display related flags, not defined yet. ulGPUCapInfo: bit[0]=0: TMDS/HDMI Coherent Mode use cascade PLL mode. =1: TMDS/HDMI Coherent Mode use signel PLL mode. bit[3]=0: Enable HW AUX mode detection logic =1: Disable HW AUX mode dettion logic ulSB_MMIO_Base_Addr: Physical Base address to SB MMIO space. Driver needs to initialize it for SMU usage. -usRequestedPWMFreqInHz: When it's set to 0x0 by SBIOS: the LCD BackLight is not controlled by GPU(SW). +usRequestedPWMFreqInHz: When it's set to 0x0 by SBIOS: the LCD BackLight is not controlled by GPU(SW). Any attempt to change BL using VBIOS function or enable VariBri from PP table is not effective since ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==0; - + When it's set to a non-zero frequency, the BackLight is controlled by GPU (SW) in one of two ways below: 1. SW uses the GPU BL PWM output to control the BL, in chis case, this non-zero frequency determines what freq GPU should use; VBIOS will set up proper PWM frequency and ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1,as the result, - Changing BL using VBIOS function is functional in both driver and non-driver present environment; + Changing BL using VBIOS function is functional in both driver and non-driver present environment; and enabling VariBri under the driver environment from PP table is optional. 2. SW uses other means to control BL (like DPCD),this non-zero frequency serves as a flag only indicating that BL control from GPU is expected. VBIOS will NOT set up PWM frequency but make ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1 Changing BL using VBIOS function could be functional in both driver and non-driver present environment,but - it's per platform + it's per platform and enabling VariBri under the driver environment from PP table is optional. -ucHtcTmpLmt: Refer to D18F3x64 bit[22:16], HtcTmpLmt. +ucHtcTmpLmt: Refer to D18F3x64 bit[22:16], HtcTmpLmt. Threshold on value to enter HTC_active state. -ucHtcHystLmt: Refer to D18F3x64 bit[27:24], HtcHystLmt. +ucHtcHystLmt: Refer to D18F3x64 bit[27:24], HtcHystLmt. To calculate threshold off value to exit HTC_active state, which is Threshold on vlaue minus ucHtcHystLmt. ulMinEngineClock: Minimum SCLK allowed in 10kHz unit. This is calculated based on WRCK Fuse settings. -ulSystemConfig: Bit[0]=0: PCIE Power Gating Disabled +ulSystemConfig: Bit[0]=0: PCIE Power Gating Disabled =1: PCIE Power Gating Enabled Bit[1]=0: DDR-DLL shut-down feature disabled. 1: DDR-DLL shut-down feature enabled. Bit[2]=0: DDR-PLL Power down feature disabled. - 1: DDR-PLL Power down feature enabled. + 1: DDR-PLL Power down feature enabled. ulCPUCapInfo: TBD usNBP0Voltage: VID for voltage on NB P0 State -usNBP1Voltage: VID for voltage on NB P1 State +usNBP1Voltage: VID for voltage on NB P1 State usBootUpNBVoltage: Voltage Index of GNB voltage configured by SBIOS, which is suffcient to support VBIOS DISPCLK requirement. usExtDispConnInfoOffset: Offset to sExtDispConnInfo inside the structure usPanelRefreshRateRange: Bit vector for LCD supported refresh rate range. If DRR is requestd by the platform, at least two bits need to be set @@ -4922,24 +4922,24 @@ usPanelRefreshRateRange: Bit vector for LCD supported refresh rate rang SUPPORTED_LCD_REFRESHRATE_50Hz 0x0010 SUPPORTED_LCD_REFRESHRATE_60Hz 0x0020 ucMemoryType: [3:0]=1:DDR1;=2:DDR2;=3:DDR3.[7:4] is reserved. -ucUMAChannelNumber: System memory channel numbers. +ucUMAChannelNumber: System memory channel numbers. ulCSR_M3_ARB_CNTL_DEFAULT[10]: Arrays with values for CSR M3 arbiter for default ulCSR_M3_ARB_CNTL_UVD[10]: Arrays with values for CSR M3 arbiter for UVD playback. ulCSR_M3_ARB_CNTL_FS3D[10]: Arrays with values for CSR M3 arbiter for Full Screen 3D applications. -sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high -ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns. -ulMinimumNClk: Minimum NCLK speed among all NB-Pstates to calcualte data reconnection latency. Unit in 10kHz. +sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high +ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns. +ulMinimumNClk: Minimum NCLK speed among all NB-Pstates to calcualte data reconnection latency. Unit in 10kHz. ulIdleNClk: NCLK speed while memory runs in self-refresh state. Unit in 10kHz. ulDDR_DLL_PowerUpTime: DDR PHY DLL power up time. Unit in ns. ulDDR_PLL_PowerUpTime: DDR PHY PLL power up time. Unit in ns. usPCIEClkSSPercentage: PCIE Clock Spred Spectrum Percentage in unit 0.01%; 100 mean 1%. usPCIEClkSSType: PCIE Clock Spred Spectrum Type. 0 for Down spread(default); 1 for Center spread. -usLvdsSSPercentage: LVDS panel ( not include eDP ) Spread Spectrum Percentage in unit of 0.01%, =0, use VBIOS default setting. -usLvdsSSpreadRateIn10Hz: LVDS panel ( not include eDP ) Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. -usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. -usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. -usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. -usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usLvdsSSPercentage: LVDS panel ( not include eDP ) Spread Spectrum Percentage in unit of 0.01%, =0, use VBIOS default setting. +usLvdsSSpreadRateIn10Hz: LVDS panel ( not include eDP ) Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. +usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. +usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. usMaxLVDSPclkFreqInSingleLink: Max pixel clock LVDS panel single link, if=0 means VBIOS use default threhold, right now it is 85Mhz ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 panel in LDI mode, =1: LVDS 888 panel in FPDI mode [bit1] LVDS panel lower and upper link mapping =0: lower link and upper link not swap, =1: lower link and upper link are swapped @@ -4951,9 +4951,9 @@ ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 pan // this Table is used for Liano/Ontario APU typedef struct _ATOM_FUSION_SYSTEM_INFO_V1 { - ATOM_INTEGRATED_SYSTEM_INFO_V6 sIntegratedSysInfo; - ULONG ulPowerplayTable[128]; -}ATOM_FUSION_SYSTEM_INFO_V1; + ATOM_INTEGRATED_SYSTEM_INFO_V6 sIntegratedSysInfo; + ULONG ulPowerplayTable[128]; +}ATOM_FUSION_SYSTEM_INFO_V1; typedef struct _ATOM_TDP_CONFIG_BITS @@ -4980,8 +4980,8 @@ typedef union _ATOM_TDP_CONFIG /********************************************************************************************************************** ATOM_FUSION_SYSTEM_INFO_V1 Description sIntegratedSysInfo: refer to ATOM_INTEGRATED_SYSTEM_INFO_V6 definition. -ulPowerplayTable[128]: This 512 bytes memory is used to save ATOM_PPLIB_POWERPLAYTABLE3, starting form ulPowerplayTable[0] -**********************************************************************************************************************/ +ulPowerplayTable[128]: This 512 bytes memory is used to save ATOM_PPLIB_POWERPLAYTABLE3, starting form ulPowerplayTable[0] +**********************************************************************************************************************/ // this IntegrateSystemInfoTable is used for Trinity APU typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 @@ -4999,14 +4999,14 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 UCHAR ucHtcTmpLmt; UCHAR ucHtcHystLmt; ULONG ulMinEngineClock; - ULONG ulSystemConfig; + ULONG ulSystemConfig; ULONG ulCPUCapInfo; - USHORT usNBP0Voltage; + USHORT usNBP0Voltage; USHORT usNBP1Voltage; - USHORT usBootUpNBVoltage; + USHORT usBootUpNBVoltage; USHORT usExtDispConnInfoOffset; - USHORT usPanelRefreshRateRange; - UCHAR ucMemoryType; + USHORT usPanelRefreshRateRange; + UCHAR ucMemoryType; UCHAR ucUMAChannelNumber; UCHAR strVBIOSMsg[40]; ATOM_TDP_CONFIG asTdpConfig; @@ -5027,10 +5027,10 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 USHORT usDVISSpreadRateIn10Hz; ULONG SclkDpmBoostMargin; ULONG SclkDpmThrottleMargin; - USHORT SclkDpmTdpLimitPG; + USHORT SclkDpmTdpLimitPG; USHORT SclkDpmTdpLimitBoost; ULONG ulBoostEngineCLock; - UCHAR ulBoostVid_2bit; + UCHAR ulBoostVid_2bit; UCHAR EnableBoost; USHORT GnbTdpLimit; USHORT usMaxLVDSPclkFreqInSingleLink; @@ -5046,7 +5046,7 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 UCHAR ucMinAllowedBL_Level; ULONG ulLCDBitDepthControlVal; ULONG ulNbpStateMemclkFreq[4]; - USHORT usNBP2Voltage; + USHORT usNBP2Voltage; USHORT usNBP3Voltage; ULONG ulNbpStateNClkFreq[4]; UCHAR ucNBDPMEnable; @@ -5077,21 +5077,21 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 /********************************************************************************************************************** ATOM_INTEGRATED_SYSTEM_INFO_V1_7 Description ulBootUpEngineClock: VBIOS bootup Engine clock frequency, in 10kHz unit. if it is equal 0, then VBIOS use pre-defined bootup engine clock -ulDentistVCOFreq: Dentist VCO clock in 10kHz unit. -ulBootUpUMAClock: System memory boot up clock frequency in 10Khz unit. +ulDentistVCOFreq: Dentist VCO clock in 10kHz unit. +ulBootUpUMAClock: System memory boot up clock frequency in 10Khz unit. sDISPCLK_Voltage: Report Display clock voltage requirement. - + ulBootUpReqDisplayVector: VBIOS boot up display IDs, following are supported devices in Trinity projects: ATOM_DEVICE_CRT1_SUPPORT 0x0001 - ATOM_DEVICE_DFP1_SUPPORT 0x0008 - ATOM_DEVICE_DFP6_SUPPORT 0x0040 - ATOM_DEVICE_DFP2_SUPPORT 0x0080 - ATOM_DEVICE_DFP3_SUPPORT 0x0200 - ATOM_DEVICE_DFP4_SUPPORT 0x0400 + ATOM_DEVICE_DFP1_SUPPORT 0x0008 + ATOM_DEVICE_DFP6_SUPPORT 0x0040 + ATOM_DEVICE_DFP2_SUPPORT 0x0080 + ATOM_DEVICE_DFP3_SUPPORT 0x0200 + ATOM_DEVICE_DFP4_SUPPORT 0x0400 ATOM_DEVICE_DFP5_SUPPORT 0x0800 ATOM_DEVICE_LCD1_SUPPORT 0x0002 -ulOtherDisplayMisc: bit[0]=0: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is not supported by SBIOS. - =1: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is supported by SBIOS. +ulOtherDisplayMisc: bit[0]=0: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is not supported by SBIOS. + =1: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is supported by SBIOS. bit[1]=0: INT15 callback function Get boot display( ax=4e08, bl=01h) is not supported by SBIOS =1: INT15 callback function Get boot display( ax=4e08, bl=01h) is supported by SBIOS bit[2]=0: INT15 callback function Get panel Expansion ( ax=4e08, bl=02h) is not supported by SBIOS @@ -5104,41 +5104,40 @@ ulGPUCapInfo: bit[0]=0: TMDS/HDMI Coherent Mode use cascade =1: DP mode use single PLL mode bit[3]=0: Enable AUX HW mode detection logic =1: Disable AUX HW mode detection logic - + ulSB_MMIO_Base_Addr: Physical Base address to SB MMIO space. Driver needs to initialize it for SMU usage. -usRequestedPWMFreqInHz: When it's set to 0x0 by SBIOS: the LCD BackLight is not controlled by GPU(SW). +usRequestedPWMFreqInHz: When it's set to 0x0 by SBIOS: the LCD BackLight is not controlled by GPU(SW). Any attempt to change BL using VBIOS function or enable VariBri from PP table is not effective since ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==0; - + When it's set to a non-zero frequency, the BackLight is controlled by GPU (SW) in one of two ways below: 1. SW uses the GPU BL PWM output to control the BL, in chis case, this non-zero frequency determines what freq GPU should use; VBIOS will set up proper PWM frequency and ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1,as the result, - Changing BL using VBIOS function is functional in both driver and non-driver present environment; + Changing BL using VBIOS function is functional in both driver and non-driver present environment; and enabling VariBri under the driver environment from PP table is optional. 2. SW uses other means to control BL (like DPCD),this non-zero frequency serves as a flag only indicating that BL control from GPU is expected. VBIOS will NOT set up PWM frequency but make ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1 - Changing BL using VBIOS function could be functional in both driver and non-driver present environment,but - it's per platform - and enabling VariBri under the driver environment from PP table is optional. + Changing BL using VBIOS function could be functional in both driver and non-driver present environment, but + it's per platform and enabling VariBri under the driver environment from PP table is optional. -ucHtcTmpLmt: Refer to D18F3x64 bit[22:16], HtcTmpLmt. +ucHtcTmpLmt: Refer to D18F3x64 bit[22:16], HtcTmpLmt. Threshold on value to enter HTC_active state. -ucHtcHystLmt: Refer to D18F3x64 bit[27:24], HtcHystLmt. +ucHtcHystLmt: Refer to D18F3x64 bit[27:24], HtcHystLmt. To calculate threshold off value to exit HTC_active state, which is Threshold on vlaue minus ucHtcHystLmt. ulMinEngineClock: Minimum SCLK allowed in 10kHz unit. This is calculated based on WRCK Fuse settings. -ulSystemConfig: Bit[0]=0: PCIE Power Gating Disabled +ulSystemConfig: Bit[0]=0: PCIE Power Gating Disabled =1: PCIE Power Gating Enabled Bit[1]=0: DDR-DLL shut-down feature disabled. 1: DDR-DLL shut-down feature enabled. Bit[2]=0: DDR-PLL Power down feature disabled. - 1: DDR-PLL Power down feature enabled. + 1: DDR-PLL Power down feature enabled. ulCPUCapInfo: TBD usNBP0Voltage: VID for voltage on NB P0 State -usNBP1Voltage: VID for voltage on NB P1 State +usNBP1Voltage: VID for voltage on NB P1 State usNBP2Voltage: VID for voltage on NB P2 State -usNBP3Voltage: VID for voltage on NB P3 State +usNBP3Voltage: VID for voltage on NB P3 State usBootUpNBVoltage: Voltage Index of GNB voltage configured by SBIOS, which is suffcient to support VBIOS DISPCLK requirement. usExtDispConnInfoOffset: Offset to sExtDispConnInfo inside the structure usPanelRefreshRateRange: Bit vector for LCD supported refresh rate range. If DRR is requestd by the platform, at least two bits need to be set @@ -5148,24 +5147,24 @@ usPanelRefreshRateRange: Bit vector for LCD supported refresh rate rang SUPPORTED_LCD_REFRESHRATE_50Hz 0x0010 SUPPORTED_LCD_REFRESHRATE_60Hz 0x0020 ucMemoryType: [3:0]=1:DDR1;=2:DDR2;=3:DDR3.[7:4] is reserved. -ucUMAChannelNumber: System memory channel numbers. +ucUMAChannelNumber: System memory channel numbers. ulCSR_M3_ARB_CNTL_DEFAULT[10]: Arrays with values for CSR M3 arbiter for default ulCSR_M3_ARB_CNTL_UVD[10]: Arrays with values for CSR M3 arbiter for UVD playback. ulCSR_M3_ARB_CNTL_FS3D[10]: Arrays with values for CSR M3 arbiter for Full Screen 3D applications. -sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high -ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns. -ulMinimumNClk: Minimum NCLK speed among all NB-Pstates to calcualte data reconnection latency. Unit in 10kHz. +sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high +ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns. +ulMinimumNClk: Minimum NCLK speed among all NB-Pstates to calcualte data reconnection latency. Unit in 10kHz. ulIdleNClk: NCLK speed while memory runs in self-refresh state. Unit in 10kHz. ulDDR_DLL_PowerUpTime: DDR PHY DLL power up time. Unit in ns. ulDDR_PLL_PowerUpTime: DDR PHY PLL power up time. Unit in ns. usPCIEClkSSPercentage: PCIE Clock Spread Spectrum Percentage in unit 0.01%; 100 mean 1%. usPCIEClkSSType: PCIE Clock Spread Spectrum Type. 0 for Down spread(default); 1 for Center spread. -usLvdsSSPercentage: LVDS panel ( not include eDP ) Spread Spectrum Percentage in unit of 0.01%, =0, use VBIOS default setting. -usLvdsSSpreadRateIn10Hz: LVDS panel ( not include eDP ) Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. -usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. -usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. -usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. -usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usLvdsSSPercentage: LVDS panel ( not include eDP ) Spread Spectrum Percentage in unit of 0.01%, =0, use VBIOS default setting. +usLvdsSSpreadRateIn10Hz: LVDS panel ( not include eDP ) Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. +usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. +usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. usMaxLVDSPclkFreqInSingleLink: Max pixel clock LVDS panel single link, if=0 means VBIOS use default threhold, right now it is 85Mhz ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 panel in LDI mode, =1: LVDS 888 panel in FPDI mode [bit1] LVDS panel lower and upper link mapping =0: lower link and upper link not swap, =1: lower link and upper link are swapped @@ -5173,40 +5172,40 @@ ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 pan [bit3] LVDS parameter override enable =0: ucLvdsMisc parameter are not used =1: ucLvdsMisc parameter should be used [bit4] Polarity of signal sent to digital BLON output pin. =0: not inverted(active high) =1: inverted ( active low ) [bit5] Travid LVDS output voltage override enable, when =1, use ucTravisLVDSVolAdjust value to overwrite Traivs register LVDS_CTRL_4 -ucTravisLVDSVolAdjust When ucLVDSMisc[5]=1,it means platform SBIOS want to overwrite TravisLVDSVoltage. Then VBIOS will use ucTravisLVDSVolAdjust +ucTravisLVDSVolAdjust When ucLVDSMisc[5]=1,it means platform SBIOS want to overwrite TravisLVDSVoltage. Then VBIOS will use ucTravisLVDSVolAdjust value to program Travis register LVDS_CTRL_4 ucLVDSPwrOnSeqDIGONtoDE_in4Ms: LVDS power up sequence time in unit of 4ms, time delay from DIGON signal active to data enable signal active( DE ). - =0 mean use VBIOS default which is 8 ( 32ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. + =0 mean use VBIOS default which is 8 ( 32ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOnDEtoVARY_BL_in4Ms: LVDS power up sequence time in unit of 4ms., time delay from DE( data enable ) active to Vary Brightness enable signal active( VARY_BL ). - =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. +ucLVDSPwrOnDEtoVARY_BL_in4Ms: LVDS power up sequence time in unit of 4ms., time delay from DE( data enable ) active to Vary Brightness enable signal active( VARY_BL ). + =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOffVARY_BLtoDE_in4Ms: LVDS power down sequence time in unit of 4ms, time delay from data enable ( DE ) signal off to LCDVCC (DIGON) off. +ucLVDSPwrOffVARY_BLtoDE_in4Ms: LVDS power down sequence time in unit of 4ms, time delay from data enable ( DE ) signal off to LCDVCC (DIGON) off. =0 mean use VBIOS default delay which is 8 ( 32ms ). The LVDS power down sequence is as following: BLON->VARY_BL->DE->DIGON This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOffDEtoDIGON_in4Ms: LVDS power down sequence time in unit of 4ms, time delay from vary brightness enable signal( VARY_BL) off to data enable ( DE ) signal off. +ucLVDSPwrOffDEtoDIGON_in4Ms: LVDS power down sequence time in unit of 4ms, time delay from vary brightness enable signal( VARY_BL) off to data enable ( DE ) signal off. =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power down sequence is as following: BLON->VARY_BL->DE->DIGON This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSOffToOnDelay_in4Ms: LVDS power down sequence time in unit of 4ms. Time delay from DIGON signal off to DIGON signal active. +ucLVDSOffToOnDelay_in4Ms: LVDS power down sequence time in unit of 4ms. Time delay from DIGON signal off to DIGON signal active. =0 means to use VBIOS default delay which is 125 ( 500ms ). This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. ucLVDSPwrOnSeqVARY_BLtoBLON_in4Ms: - LVDS power up sequence time in unit of 4ms. Time delay from VARY_BL signal on to DLON signal active. + LVDS power up sequence time in unit of 4ms. Time delay from VARY_BL signal on to DLON signal active. =0 means to use VBIOS default delay which is 0 ( 0ms ). This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOffSeqBLONtoVARY_BL_in4Ms: - LVDS power down sequence time in unit of 4ms. Time delay from BLON signal off to VARY_BL signal off. +ucLVDSPwrOffSeqBLONtoVARY_BL_in4Ms: + LVDS power down sequence time in unit of 4ms. Time delay from BLON signal off to VARY_BL signal off. =0 means to use VBIOS default delay which is 0 ( 0ms ). This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucMinAllowedBL_Level: Lowest LCD backlight PWM level. This is customer platform specific parameters. By default it is 0. +ucMinAllowedBL_Level: Lowest LCD backlight PWM level. This is customer platform specific parameters. By default it is 0. -ulNbpStateMemclkFreq[4]: system memory clock frequncey in unit of 10Khz in different NB pstate. +ulNbpStateMemclkFreq[4]: system memory clock frequncey in unit of 10Khz in different NB pstate. **********************************************************************************************************************/ @@ -5226,13 +5225,13 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_8 UCHAR ucHtcTmpLmt; UCHAR ucHtcHystLmt; ULONG ulReserved2; - ULONG ulSystemConfig; + ULONG ulSystemConfig; ULONG ulCPUCapInfo; ULONG ulReserved3; USHORT usGPUReservedSysMemSize; USHORT usExtDispConnInfoOffset; - USHORT usPanelRefreshRateRange; - UCHAR ucMemoryType; + USHORT usPanelRefreshRateRange; + UCHAR ucMemoryType; UCHAR ucUMAChannelNumber; UCHAR strVBIOSMsg[40]; ATOM_TDP_CONFIG asTdpConfig; @@ -5267,21 +5266,21 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_8 UCHAR ucMinAllowedBL_Level; ULONG ulLCDBitDepthControlVal; ULONG ulNbpStateMemclkFreq[4]; - ULONG ulReserved6; + ULONG ulReserved6; ULONG ulNbpStateNClkFreq[4]; - USHORT usNBPStateVoltage[4]; - USHORT usBootUpNBVoltage; - USHORT usReserved2; + USHORT usNBPStateVoltage[4]; + USHORT usBootUpNBVoltage; + USHORT usReserved2; ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO sExtDispConnInfo; }ATOM_INTEGRATED_SYSTEM_INFO_V1_8; /********************************************************************************************************************** ATOM_INTEGRATED_SYSTEM_INFO_V1_8 Description ulBootUpEngineClock: VBIOS bootup Engine clock frequency, in 10kHz unit. if it is equal 0, then VBIOS use pre-defined bootup engine clock -ulDentistVCOFreq: Dentist VCO clock in 10kHz unit. -ulBootUpUMAClock: System memory boot up clock frequency in 10Khz unit. +ulDentistVCOFreq: Dentist VCO clock in 10kHz unit. +ulBootUpUMAClock: System memory boot up clock frequency in 10Khz unit. sDISPCLK_Voltage: Report Display clock frequency requirement on GNB voltage(up to 4 voltage levels). - + ulBootUpReqDisplayVector: VBIOS boot up display IDs, following are supported devices in Trinity projects: ATOM_DEVICE_CRT1_SUPPORT 0x0001 ATOM_DEVICE_DFP1_SUPPORT 0x0008 @@ -5292,8 +5291,8 @@ ulBootUpReqDisplayVector: VBIOS boot up display IDs, following are suppo ATOM_DEVICE_DFP5_SUPPORT 0x0800 ATOM_DEVICE_LCD1_SUPPORT 0x0002 -ulVBIOSMisc: Miscellenous flags for VBIOS requirement and interface - bit[0]=0: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is not supported by SBIOS. +ulVBIOSMisc: Miscellenous flags for VBIOS requirement and interface + bit[0]=0: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is not supported by SBIOS. =1: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is supported by SBIOS. bit[1]=0: INT15 callback function Get boot display( ax=4e08, bl=01h) is not supported by SBIOS =1: INT15 callback function Get boot display( ax=4e08, bl=01h) is supported by SBIOS @@ -5308,34 +5307,33 @@ ulGPUCapInfo: bit[0~2]= Reserved bit[4]=0: Disable DFS bypass feature =1: Enable DFS bypass feature -usRequestedPWMFreqInHz: When it's set to 0x0 by SBIOS: the LCD BackLight is not controlled by GPU(SW). +usRequestedPWMFreqInHz: When it's set to 0x0 by SBIOS: the LCD BackLight is not controlled by GPU(SW). Any attempt to change BL using VBIOS function or enable VariBri from PP table is not effective since ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==0; - + When it's set to a non-zero frequency, the BackLight is controlled by GPU (SW) in one of two ways below: 1. SW uses the GPU BL PWM output to control the BL, in chis case, this non-zero frequency determines what freq GPU should use; VBIOS will set up proper PWM frequency and ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1,as the result, - Changing BL using VBIOS function is functional in both driver and non-driver present environment; + Changing BL using VBIOS function is functional in both driver and non-driver present environment; and enabling VariBri under the driver environment from PP table is optional. 2. SW uses other means to control BL (like DPCD),this non-zero frequency serves as a flag only indicating that BL control from GPU is expected. VBIOS will NOT set up PWM frequency but make ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1 - Changing BL using VBIOS function could be functional in both driver and non-driver present environment,but - it's per platform - and enabling VariBri under the driver environment from PP table is optional. + Changing BL using VBIOS function could be functional in both driver and non-driver present environment, but + it's per platform and enabling VariBri under the driver environment from PP table is optional. ucHtcTmpLmt: Refer to D18F3x64 bit[22:16], HtcTmpLmt. Threshold on value to enter HTC_active state. -ucHtcHystLmt: Refer to D18F3x64 bit[27:24], HtcHystLmt. +ucHtcHystLmt: Refer to D18F3x64 bit[27:24], HtcHystLmt. To calculate threshold off value to exit HTC_active state, which is Threshold on vlaue minus ucHtcHystLmt. -ulSystemConfig: Bit[0]=0: PCIE Power Gating Disabled +ulSystemConfig: Bit[0]=0: PCIE Power Gating Disabled =1: PCIE Power Gating Enabled Bit[1]=0: DDR-DLL shut-down feature disabled. 1: DDR-DLL shut-down feature enabled. Bit[2]=0: DDR-PLL Power down feature disabled. - 1: DDR-PLL Power down feature enabled. + 1: DDR-PLL Power down feature enabled. Bit[3]=0: GNB DPM is disabled - =1: GNB DPM is enabled + =1: GNB DPM is enabled ulCPUCapInfo: TBD usExtDispConnInfoOffset: Offset to sExtDispConnInfo inside the structure @@ -5347,29 +5345,29 @@ usPanelRefreshRateRange: Bit vector for LCD supported refresh rate rang SUPPORTED_LCD_REFRESHRATE_60Hz 0x0020 ucMemoryType: [3:0]=1:DDR1;=2:DDR2;=3:DDR3;=5:GDDR5; [7:4] is reserved. -ucUMAChannelNumber: System memory channel numbers. +ucUMAChannelNumber: System memory channel numbers. -strVBIOSMsg[40]: VBIOS boot up customized message string +strVBIOSMsg[40]: VBIOS boot up customized message string -sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high +sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high -ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns. +ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns. ulIdleNClk: NCLK speed while memory runs in self-refresh state, used to calculate self-refresh latency. Unit in 10kHz. ulDDR_DLL_PowerUpTime: DDR PHY DLL power up time. Unit in ns. ulDDR_PLL_PowerUpTime: DDR PHY PLL power up time. Unit in ns. usPCIEClkSSPercentage: PCIE Clock Spread Spectrum Percentage in unit 0.01%; 100 mean 1%. usPCIEClkSSType: PCIE Clock Spread Spectrum Type. 0 for Down spread(default); 1 for Center spread. -usLvdsSSPercentage: LVDS panel ( not include eDP ) Spread Spectrum Percentage in unit of 0.01%, =0, use VBIOS default setting. -usLvdsSSpreadRateIn10Hz: LVDS panel ( not include eDP ) Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. -usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. -usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. -usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. -usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usLvdsSSPercentage: LVDS panel ( not include eDP ) Spread Spectrum Percentage in unit of 0.01%, =0, use VBIOS default setting. +usLvdsSSpreadRateIn10Hz: LVDS panel ( not include eDP ) Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. +usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. +usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. +usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. usGPUReservedSysMemSize: Reserved system memory size for ACP engine in APU GNB, units in MB. 0/2/4MB based on CMOS options, current default could be 0MB. KV only, not on KB. -ulGPUReservedSysMemBaseAddrLo: Low 32 bits base address to the reserved system memory. -ulGPUReservedSysMemBaseAddrHi: High 32 bits base address to the reserved system memory. +ulGPUReservedSysMemBaseAddrLo: Low 32 bits base address to the reserved system memory. +ulGPUReservedSysMemBaseAddrHi: High 32 bits base address to the reserved system memory. usMaxLVDSPclkFreqInSingleLink: Max pixel clock LVDS panel single link, if=0 means VBIOS use default threhold, right now it is 85Mhz ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 panel in LDI mode, =1: LVDS 888 panel in FPDI mode @@ -5378,45 +5376,45 @@ ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 pan [bit3] LVDS parameter override enable =0: ucLvdsMisc parameter are not used =1: ucLvdsMisc parameter should be used [bit4] Polarity of signal sent to digital BLON output pin. =0: not inverted(active high) =1: inverted ( active low ) [bit5] Travid LVDS output voltage override enable, when =1, use ucTravisLVDSVolAdjust value to overwrite Traivs register LVDS_CTRL_4 -ucTravisLVDSVolAdjust When ucLVDSMisc[5]=1,it means platform SBIOS want to overwrite TravisLVDSVoltage. Then VBIOS will use ucTravisLVDSVolAdjust +ucTravisLVDSVolAdjust When ucLVDSMisc[5]=1,it means platform SBIOS want to overwrite TravisLVDSVoltage. Then VBIOS will use ucTravisLVDSVolAdjust value to program Travis register LVDS_CTRL_4 -ucLVDSPwrOnSeqDIGONtoDE_in4Ms: +ucLVDSPwrOnSeqDIGONtoDE_in4Ms: LVDS power up sequence time in unit of 4ms, time delay from DIGON signal active to data enable signal active( DE ). - =0 mean use VBIOS default which is 8 ( 32ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. + =0 mean use VBIOS default which is 8 ( 32ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOnDEtoVARY_BL_in4Ms: - LVDS power up sequence time in unit of 4ms., time delay from DE( data enable ) active to Vary Brightness enable signal active( VARY_BL ). - =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. +ucLVDSPwrOnDEtoVARY_BL_in4Ms: + LVDS power up sequence time in unit of 4ms., time delay from DE( data enable ) active to Vary Brightness enable signal active( VARY_BL ). + =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON. This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOffVARY_BLtoDE_in4Ms: - LVDS power down sequence time in unit of 4ms, time delay from data enable ( DE ) signal off to LCDVCC (DIGON) off. +ucLVDSPwrOffVARY_BLtoDE_in4Ms: + LVDS power down sequence time in unit of 4ms, time delay from data enable ( DE ) signal off to LCDVCC (DIGON) off. =0 mean use VBIOS default delay which is 8 ( 32ms ). The LVDS power down sequence is as following: BLON->VARY_BL->DE->DIGON This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOffDEtoDIGON_in4Ms: - LVDS power down sequence time in unit of 4ms, time delay from vary brightness enable signal( VARY_BL) off to data enable ( DE ) signal off. +ucLVDSPwrOffDEtoDIGON_in4Ms: + LVDS power down sequence time in unit of 4ms, time delay from vary brightness enable signal( VARY_BL) off to data enable ( DE ) signal off. =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power down sequence is as following: BLON->VARY_BL->DE->DIGON This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSOffToOnDelay_in4Ms: - LVDS power down sequence time in unit of 4ms. Time delay from DIGON signal off to DIGON signal active. +ucLVDSOffToOnDelay_in4Ms: + LVDS power down sequence time in unit of 4ms. Time delay from DIGON signal off to DIGON signal active. =0 means to use VBIOS default delay which is 125 ( 500ms ). This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. ucLVDSPwrOnSeqVARY_BLtoBLON_in4Ms: - LVDS power up sequence time in unit of 4ms. Time delay from VARY_BL signal on to DLON signal active. + LVDS power up sequence time in unit of 4ms. Time delay from VARY_BL signal on to DLON signal active. =0 means to use VBIOS default delay which is 0 ( 0ms ). This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucLVDSPwrOffSeqBLONtoVARY_BL_in4Ms: - LVDS power down sequence time in unit of 4ms. Time delay from BLON signal off to VARY_BL signal off. +ucLVDSPwrOffSeqBLONtoVARY_BL_in4Ms: + LVDS power down sequence time in unit of 4ms. Time delay from BLON signal off to VARY_BL signal off. =0 means to use VBIOS default delay which is 0 ( 0ms ). This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable. -ucMinAllowedBL_Level: Lowest LCD backlight PWM level. This is customer platform specific parameters. By default it is 0. +ucMinAllowedBL_Level: Lowest LCD backlight PWM level. This is customer platform specific parameters. By default it is 0. ulLCDBitDepthControlVal: GPU display control encoder bit dither control setting, used to program register mmFMT_BIT_DEPTH_CONTROL ulNbpStateMemclkFreq[4]: system memory clock frequncey in unit of 10Khz in different NB P-State(P0, P1, P2 & P3). ulNbpStateNClkFreq[4]: NB P-State NClk frequency in different NB P-State usNBPStateVoltage[4]: NB P-State (P0/P1 & P2/P3) voltage; NBP3 refers to lowes voltage -usBootUpNBVoltage: NB P-State voltage during boot up before driver loaded +usBootUpNBVoltage: NB P-State voltage during boot up before driver loaded sExtDispConnInfo: Display connector information table provided to VBIOS **********************************************************************************************************************/ @@ -5426,7 +5424,7 @@ typedef struct _ATOM_FUSION_SYSTEM_INFO_V2 { ATOM_INTEGRATED_SYSTEM_INFO_V1_8 sIntegratedSysInfo; // refer to ATOM_INTEGRATED_SYSTEM_INFO_V1_8 definition ULONG ulPowerplayTable[128]; // Update comments here to link new powerplay table definition structure -}ATOM_FUSION_SYSTEM_INFO_V2; +}ATOM_FUSION_SYSTEM_INFO_V2; /**************************************************************************/ @@ -5451,13 +5449,13 @@ typedef struct _ATOM_I2C_DEVICE_SETUP_INFO UCHAR ucSSChipID; //SS chip being used UCHAR ucSSChipSlaveAddr; //Slave Address to set up this SS chip UCHAR ucNumOfI2CDataRecords; //number of data block - ATOM_I2C_DATA_RECORD asI2CData[1]; + ATOM_I2C_DATA_RECORD asI2CData[1]; }ATOM_I2C_DEVICE_SETUP_INFO; //========================================================================================== typedef struct _ATOM_ASIC_MVDD_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_I2C_DEVICE_SETUP_INFO asI2CSetup[1]; }ATOM_ASIC_MVDD_INFO; @@ -5513,14 +5511,14 @@ typedef struct _ATOM_ASIC_SS_ASSIGNMENT_V2 typedef struct _ATOM_ASIC_INTERNAL_SS_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_ASIC_SS_ASSIGNMENT asSpreadSpectrum[4]; }ATOM_ASIC_INTERNAL_SS_INFO; typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V2 { - ATOM_COMMON_TABLE_HEADER sHeader; - ATOM_ASIC_SS_ASSIGNMENT_V2 asSpreadSpectrum[1]; //this is point only. + ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_ASIC_SS_ASSIGNMENT_V2 asSpreadSpectrum[1]; //this is point only. }ATOM_ASIC_INTERNAL_SS_INFO_V2; typedef struct _ATOM_ASIC_SS_ASSIGNMENT_V3 @@ -5541,8 +5539,8 @@ typedef struct _ATOM_ASIC_SS_ASSIGNMENT_V3 typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 { - ATOM_COMMON_TABLE_HEADER sHeader; - ATOM_ASIC_SS_ASSIGNMENT_V3 asSpreadSpectrum[1]; //this is pointer only. + ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_ASIC_SS_ASSIGNMENT_V3 asSpreadSpectrum[1]; //this is pointer only. }ATOM_ASIC_INTERNAL_SS_INFO_V3; @@ -5559,7 +5557,7 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 #define ATOM_I2C_CHANNEL_STATUS1_DEF 9 #define ATOM_INTERNAL_TIMER_DEF 10 -// BIOS_0_SCRATCH Definition +// BIOS_0_SCRATCH Definition #define ATOM_S0_CRT1_MONO 0x00000001L #define ATOM_S0_CRT1_COLOR 0x00000002L #define ATOM_S0_CRT1_MASK (ATOM_S0_CRT1_MONO+ATOM_S0_CRT1_COLOR) @@ -5597,14 +5595,14 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 #define ATOM_S0_DFP_MASK ATOM_S0_DFP1 | ATOM_S0_DFP2 | ATOM_S0_DFP3 | ATOM_S0_DFP4 | ATOM_S0_DFP5 | ATOM_S0_DFP6 -#define ATOM_S0_FAD_REGISTER_BUG 0x02000000L // If set, indicates we are running a PCIE asic with +#define ATOM_S0_FAD_REGISTER_BUG 0x02000000L // If set, indicates we are running a PCIE asic with // the FAD/HDP reg access bug. Bit is read by DAL, this is obsolete from RV5xx #define ATOM_S0_THERMAL_STATE_MASK 0x1C000000L #define ATOM_S0_THERMAL_STATE_SHIFT 26 #define ATOM_S0_SYSTEM_POWER_STATE_MASK 0xE0000000L -#define ATOM_S0_SYSTEM_POWER_STATE_SHIFT 29 +#define ATOM_S0_SYSTEM_POWER_STATE_SHIFT 29 #define ATOM_S0_SYSTEM_POWER_STATE_VALUE_AC 1 #define ATOM_S0_SYSTEM_POWER_STATE_VALUE_DC 2 @@ -5853,11 +5851,11 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 #define ATOM_S6_LID_STATEb0 0x40 #define ATOM_S6_DOCK_STATEb0 0x80 #define ATOM_S6_CRITICAL_STATEb1 0x01 -#define ATOM_S6_HW_I2C_BUSY_STATEb1 0x02 +#define ATOM_S6_HW_I2C_BUSY_STATEb1 0x02 #define ATOM_S6_THERMAL_STATE_CHANGEb1 0x04 #define ATOM_S6_INTERRUPT_SET_BY_BIOSb1 0x08 -#define ATOM_S6_REQ_LCD_EXPANSION_FULLb1 0x10 -#define ATOM_S6_REQ_LCD_EXPANSION_ASPEC_RATIOb1 0x20 +#define ATOM_S6_REQ_LCD_EXPANSION_FULLb1 0x10 +#define ATOM_S6_REQ_LCD_EXPANSION_ASPEC_RATIOb1 0x20 #define ATOM_S6_ACC_REQ_CRT1b2 0x01 #define ATOM_S6_ACC_REQ_LCD1b2 0x02 @@ -5915,26 +5913,26 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 // BIOS_8_SCRATCH Definition #define ATOM_S8_I2C_CHANNEL_BUSY_MASK 0x00000FFFF -#define ATOM_S8_I2C_HW_ENGINE_BUSY_MASK 0x0FFFF0000 +#define ATOM_S8_I2C_HW_ENGINE_BUSY_MASK 0x0FFFF0000 #define ATOM_S8_I2C_CHANNEL_BUSY_SHIFT 0 #define ATOM_S8_I2C_ENGINE_BUSY_SHIFT 16 // BIOS_9_SCRATCH Definition -#ifndef ATOM_S9_I2C_CHANNEL_COMPLETED_MASK +#ifndef ATOM_S9_I2C_CHANNEL_COMPLETED_MASK #define ATOM_S9_I2C_CHANNEL_COMPLETED_MASK 0x0000FFFF #endif -#ifndef ATOM_S9_I2C_CHANNEL_ABORTED_MASK +#ifndef ATOM_S9_I2C_CHANNEL_ABORTED_MASK #define ATOM_S9_I2C_CHANNEL_ABORTED_MASK 0xFFFF0000 #endif -#ifndef ATOM_S9_I2C_CHANNEL_COMPLETED_SHIFT +#ifndef ATOM_S9_I2C_CHANNEL_COMPLETED_SHIFT #define ATOM_S9_I2C_CHANNEL_COMPLETED_SHIFT 0 #endif -#ifndef ATOM_S9_I2C_CHANNEL_ABORTED_SHIFT +#ifndef ATOM_S9_I2C_CHANNEL_ABORTED_SHIFT #define ATOM_S9_I2C_CHANNEL_ABORTED_SHIFT 16 #endif - + #define ATOM_FLAG_SET 0x20 #define ATOM_FLAG_CLEAR 0 #define CLEAR_ATOM_S6_ACC_MODE ((ATOM_ACC_CHANGE_INFO_DEF << 8 )|ATOM_S6_ACC_MODE_SHIFT | ATOM_FLAG_CLEAR) @@ -5957,7 +5955,7 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 #define SET_ATOM_S6_CRITICAL_STATE ((ATOM_ACC_CHANGE_INFO_DEF << 8 )|ATOM_S6_CRITICAL_STATE_SHIFT | ATOM_FLAG_SET) #define CLEAR_ATOM_S6_CRITICAL_STATE ((ATOM_ACC_CHANGE_INFO_DEF << 8 )|ATOM_S6_CRITICAL_STATE_SHIFT | ATOM_FLAG_CLEAR) -#define SET_ATOM_S6_REQ_SCALER ((ATOM_ACC_CHANGE_INFO_DEF << 8 )|ATOM_S6_REQ_SCALER_SHIFT | ATOM_FLAG_SET) +#define SET_ATOM_S6_REQ_SCALER ((ATOM_ACC_CHANGE_INFO_DEF << 8 )|ATOM_S6_REQ_SCALER_SHIFT | ATOM_FLAG_SET) #define CLEAR_ATOM_S6_REQ_SCALER ((ATOM_ACC_CHANGE_INFO_DEF << 8 )|ATOM_S6_REQ_SCALER_SHIFT | ATOM_FLAG_CLEAR ) #define SET_ATOM_S6_REQ_SCALER_ARATIO ((ATOM_ACC_CHANGE_INFO_DEF << 8 )|ATOM_S6_REQ_SCALER_ARATIO_SHIFT | ATOM_FLAG_SET ) @@ -5972,7 +5970,7 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 #define SET_ATOM_S7_DOS_8BIT_DAC_EN ((ATOM_DOS_MODE_INFO_DEF << 8 )|ATOM_S7_DOS_8BIT_DAC_EN_SHIFT | ATOM_FLAG_SET ) #define CLEAR_ATOM_S7_DOS_8BIT_DAC_EN ((ATOM_DOS_MODE_INFO_DEF << 8 )|ATOM_S7_DOS_8BIT_DAC_EN_SHIFT | ATOM_FLAG_CLEAR ) -/****************************************************************************/ +/****************************************************************************/ //Portion II: Definitions only used in Driver /****************************************************************************/ @@ -5992,7 +5990,7 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3 #define GET_DATA_TABLE_MAJOR_REVISION GET_COMMAND_TABLE_COMMANDSET_REVISION #define GET_DATA_TABLE_MINOR_REVISION GET_COMMAND_TABLE_PARAMETER_REVISION -/****************************************************************************/ +/****************************************************************************/ //Portion III: Definitinos only used in VBIOS /****************************************************************************/ #define ATOM_DAC_SRC 0x80 @@ -6011,13 +6009,13 @@ typedef struct _MEMORY_PLLINIT_PARAMETERS #define MEMORY_PLLINIT_PS_ALLOCATION MEMORY_PLLINIT_PARAMETERS -#define GPIO_PIN_WRITE 0x01 +#define GPIO_PIN_WRITE 0x01 #define GPIO_PIN_READ 0x00 typedef struct _GPIO_PIN_CONTROL_PARAMETERS { UCHAR ucGPIO_ID; //return value, read from GPIO pins - UCHAR ucGPIOBitShift; //define which bit in uGPIOBitVal need to be update + UCHAR ucGPIOBitShift; //define which bit in uGPIOBitVal need to be update UCHAR ucGPIOBitVal; //Set/Reset corresponding bit defined in ucGPIOBitMask UCHAR ucAction; //=GPIO_PIN_WRITE: Read; =GPIO_PIN_READ: Write }GPIO_PIN_CONTROL_PARAMETERS; @@ -6026,10 +6024,10 @@ typedef struct _ENABLE_SCALER_PARAMETERS { UCHAR ucScaler; // ATOM_SCALER1, ATOM_SCALER2 UCHAR ucEnable; // ATOM_SCALER_DISABLE or ATOM_SCALER_CENTER or ATOM_SCALER_EXPANSION - UCHAR ucTVStandard; // + UCHAR ucTVStandard; // UCHAR ucPadding[1]; -}ENABLE_SCALER_PARAMETERS; -#define ENABLE_SCALER_PS_ALLOCATION ENABLE_SCALER_PARAMETERS +}ENABLE_SCALER_PARAMETERS; +#define ENABLE_SCALER_PS_ALLOCATION ENABLE_SCALER_PARAMETERS //ucEnable: #define SCALER_BYPASS_AUTO_CENTER_NO_REPLICATION 0 @@ -6049,14 +6047,14 @@ typedef struct _ENABLE_HARDWARE_ICON_CURSOR_PARAMETERS typedef struct _ENABLE_HARDWARE_ICON_CURSOR_PS_ALLOCATION { ENABLE_HARDWARE_ICON_CURSOR_PARAMETERS sEnableIcon; - ENABLE_CRTC_PARAMETERS sReserved; + ENABLE_CRTC_PARAMETERS sReserved; }ENABLE_HARDWARE_ICON_CURSOR_PS_ALLOCATION; typedef struct _ENABLE_GRAPH_SURFACE_PARAMETERS { USHORT usHight; // Image Hight USHORT usWidth; // Image Width - UCHAR ucSurface; // Surface 1 or 2 + UCHAR ucSurface; // Surface 1 or 2 UCHAR ucPadding[3]; }ENABLE_GRAPH_SURFACE_PARAMETERS; @@ -6075,7 +6073,7 @@ typedef struct _ENABLE_GRAPH_SURFACE_PARAMETERS_V1_3 USHORT usWidth; // Image Width UCHAR ucSurface; // Surface 1 or 2 UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE - USHORT usDeviceId; // Active Device Id for this surface. If no device, set to 0. + USHORT usDeviceId; // Active Device Id for this surface. If no device, set to 0. }ENABLE_GRAPH_SURFACE_PARAMETERS_V1_3; typedef struct _ENABLE_GRAPH_SURFACE_PARAMETERS_V1_4 @@ -6097,7 +6095,7 @@ typedef struct _ENABLE_GRAPH_SURFACE_PARAMETERS_V1_4 typedef struct _ENABLE_GRAPH_SURFACE_PS_ALLOCATION { - ENABLE_GRAPH_SURFACE_PARAMETERS sSetSurface; + ENABLE_GRAPH_SURFACE_PARAMETERS sSetSurface; ENABLE_YUV_PS_ALLOCATION sReserved; // Don't set this one }ENABLE_GRAPH_SURFACE_PS_ALLOCATION; @@ -6110,23 +6108,23 @@ typedef struct _MEMORY_CLEAN_UP_PARAMETERS typedef struct _GET_DISPLAY_SURFACE_SIZE_PARAMETERS { - USHORT usX_Size; //When use as input parameter, usX_Size indicates which CRTC + USHORT usX_Size; //When use as input parameter, usX_Size indicates which CRTC USHORT usY_Size; -}GET_DISPLAY_SURFACE_SIZE_PARAMETERS; +}GET_DISPLAY_SURFACE_SIZE_PARAMETERS; typedef struct _GET_DISPLAY_SURFACE_SIZE_PARAMETERS_V2 { union{ - USHORT usX_Size; //When use as input parameter, usX_Size indicates which CRTC - USHORT usSurface; + USHORT usX_Size; //When use as input parameter, usX_Size indicates which CRTC + USHORT usSurface; }; USHORT usY_Size; - USHORT usDispXStart; + USHORT usDispXStart; USHORT usDispYStart; -}GET_DISPLAY_SURFACE_SIZE_PARAMETERS_V2; +}GET_DISPLAY_SURFACE_SIZE_PARAMETERS_V2; -typedef struct _PALETTE_DATA_CONTROL_PARAMETERS_V3 +typedef struct _PALETTE_DATA_CONTROL_PARAMETERS_V3 { UCHAR ucLutId; UCHAR ucAction; @@ -6156,7 +6154,7 @@ typedef struct _INTERRUPT_SERVICE_PARAMETERS_V2 #define HDP4_INTERRUPT_ID 4 #define HDP5_INTERRUPT_ID 5 #define HDP6_INTERRUPT_ID 6 -#define SW_INTERRUPT_ID 11 +#define SW_INTERRUPT_ID 11 // ucAction #define INTERRUPT_SERVICE_GEN_SW_INT 1 @@ -6168,7 +6166,7 @@ typedef struct _INTERRUPT_SERVICE_PARAMETERS_V2 typedef struct _INDIRECT_IO_ACCESS { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; UCHAR IOAccessSequence[256]; } INDIRECT_IO_ACCESS; @@ -6197,7 +6195,7 @@ typedef struct _INDIRECT_IO_ACCESS #define INDIRECT_IO_SMU_WRITE INDIRECT_IO_SMU | INDIRECT_WRITE typedef struct _ATOM_OEM_INFO -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; ATOM_I2C_ID_CONFIG_ACCESS sucI2cId; }ATOM_OEM_INFO; @@ -6210,12 +6208,12 @@ typedef struct _ATOM_TV_MODE typedef struct _ATOM_BIOS_INT_TVSTD_MODE { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; USHORT usTV_Mode_LUT_Offset; // Pointer to standard to internal number conversion table USHORT usTV_FIFO_Offset; // Pointer to FIFO entry table USHORT usNTSC_Tbl_Offset; // Pointer to SDTV_Mode_NTSC table - USHORT usPAL_Tbl_Offset; // Pointer to SDTV_Mode_PAL table - USHORT usCV_Tbl_Offset; // Pointer to SDTV_Mode_PAL table + USHORT usPAL_Tbl_Offset; // Pointer to SDTV_Mode_PAL table + USHORT usCV_Tbl_Offset; // Pointer to SDTV_Mode_PAL table }ATOM_BIOS_INT_TVSTD_MODE; @@ -6228,13 +6226,13 @@ typedef struct _ATOM_TV_MODE_SCALER_PTR typedef struct _ATOM_STANDARD_VESA_TIMING { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_DTD_FORMAT aModeTimings[16]; // 16 is not the real array number, just for initial allocation }ATOM_STANDARD_VESA_TIMING; typedef struct _ATOM_STD_FORMAT -{ +{ USHORT usSTD_HDisp; USHORT usSTD_VDisp; USHORT usSTD_RefreshRate; @@ -6248,8 +6246,8 @@ typedef struct _ATOM_VESA_TO_EXTENDED_MODE }ATOM_VESA_TO_EXTENDED_MODE; typedef struct _ATOM_VESA_TO_INTENAL_MODE_LUT -{ - ATOM_COMMON_TABLE_HEADER sHeader; +{ + ATOM_COMMON_TABLE_HEADER sHeader; ATOM_VESA_TO_EXTENDED_MODE asVESA_ToExtendedModeInfo[76]; }ATOM_VESA_TO_INTENAL_MODE_LUT; @@ -6315,7 +6313,7 @@ typedef struct _ATOM_INIT_REG_BLOCK{ #define ACCESS_PLACEHOLDER 0x80 typedef struct _ATOM_MC_INIT_PARAM_TABLE -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; USHORT usAdjustARB_SEQDataOffset; USHORT usMCInitMemTypeTblOffset; @@ -6391,12 +6389,12 @@ typedef struct _MCuCodeHeader typedef struct _ATOM_VRAM_MODULE_V1 { ULONG ulReserved; - USHORT usEMRSValue; + USHORT usEMRSValue; USHORT usMRSValue; USHORT usReserved; UCHAR ucExtMemoryID; // An external indicator (by hardcode, callback or pin) to tell what is the current memory module UCHAR ucMemoryType; // [7:4]=0x1:DDR1;=0x2:DDR2;=0x3:DDR3;=0x4:DDR4;[3:0] reserved; - UCHAR ucMemoryVenderID; // Predefined,never change across designs or memory type/vender + UCHAR ucMemoryVenderID; // Predefined, never change across designs or memory type/vender UCHAR ucMemoryDeviceCfg; // [7:4]=0x0:4M;=0x1:8M;=0x2:16M;0x3:32M....[3:0]=0x0:x4;=0x1:x8;=0x2:x16;=0x3:x32... UCHAR ucRow; // Number of Row,in power of 2; UCHAR ucColumn; // Number of Column,in power of 2; @@ -6418,7 +6416,7 @@ typedef struct _ATOM_VRAM_MODULE_V2 ULONG ulMemoryClock; // Override of default memory clock for particular memory type USHORT usEMRS2Value; // EMRS2 Value is used for GDDR2 and GDDR4 memory type USHORT usEMRS3Value; // EMRS3 Value is used for GDDR2 and GDDR4 memory type - USHORT usEMRSValue; + USHORT usEMRSValue; USHORT usMRSValue; USHORT usReserved; UCHAR ucExtMemoryID; // An external indicator (by hardcode, callback or pin) to tell what is the current memory module @@ -6440,9 +6438,9 @@ typedef struct _ATOM_VRAM_MODULE_V2 typedef struct _ATOM_MEMORY_TIMING_FORMAT { - ULONG ulClkRange; // memory clock in 10kHz unit, when target memory clock is below this clock, use this memory timing + ULONG ulClkRange; // memory clock in 10kHz unit, when target memory clock is below this clock, use this memory timing union{ - USHORT usMRS; // mode register + USHORT usMRS; // mode register USHORT usDDR3_MR0; }; union{ @@ -6450,24 +6448,24 @@ typedef struct _ATOM_MEMORY_TIMING_FORMAT USHORT usDDR3_MR1; }; UCHAR ucCL; // CAS latency - UCHAR ucWL; // WRITE Latency + UCHAR ucWL; // WRITE Latency UCHAR uctRAS; // tRAS - UCHAR uctRC; // tRC + UCHAR uctRC; // tRC UCHAR uctRFC; // tRFC - UCHAR uctRCDR; // tRCDR + UCHAR uctRCDR; // tRCDR UCHAR uctRCDW; // tRCDW UCHAR uctRP; // tRP - UCHAR uctRRD; // tRRD + UCHAR uctRRD; // tRRD UCHAR uctWR; // tWR UCHAR uctWTR; // tWTR UCHAR uctPDIX; // tPDIX UCHAR uctFAW; // tFAW UCHAR uctAOND; // tAOND - union + union { struct { - UCHAR ucflag; // flag to control memory timing calculation. bit0= control EMRS2 Infineon - UCHAR ucReserved; + UCHAR ucflag; // flag to control memory timing calculation. bit0= control EMRS2 Infineon + UCHAR ucReserved; }; USHORT usDDR3_MR2; }; @@ -6476,71 +6474,71 @@ typedef struct _ATOM_MEMORY_TIMING_FORMAT typedef struct _ATOM_MEMORY_TIMING_FORMAT_V1 { - ULONG ulClkRange; // memory clock in 10kHz unit, when target memory clock is below this clock, use this memory timing - USHORT usMRS; // mode register + ULONG ulClkRange; // memory clock in 10kHz unit, when target memory clock is below this clock, use this memory timing + USHORT usMRS; // mode register USHORT usEMRS; // extended mode register UCHAR ucCL; // CAS latency - UCHAR ucWL; // WRITE Latency + UCHAR ucWL; // WRITE Latency UCHAR uctRAS; // tRAS - UCHAR uctRC; // tRC + UCHAR uctRC; // tRC UCHAR uctRFC; // tRFC - UCHAR uctRCDR; // tRCDR + UCHAR uctRCDR; // tRCDR UCHAR uctRCDW; // tRCDW UCHAR uctRP; // tRP - UCHAR uctRRD; // tRRD + UCHAR uctRRD; // tRRD UCHAR uctWR; // tWR UCHAR uctWTR; // tWTR UCHAR uctPDIX; // tPDIX UCHAR uctFAW; // tFAW UCHAR uctAOND; // tAOND - UCHAR ucflag; // flag to control memory timing calculation. bit0= control EMRS2 Infineon + UCHAR ucflag; // flag to control memory timing calculation. bit0= control EMRS2 Infineon ////////////////////////////////////GDDR parameters/////////////////////////////////// - UCHAR uctCCDL; // - UCHAR uctCRCRL; // - UCHAR uctCRCWL; // - UCHAR uctCKE; // - UCHAR uctCKRSE; // - UCHAR uctCKRSX; // - UCHAR uctFAW32; // - UCHAR ucMR5lo; // - UCHAR ucMR5hi; // + UCHAR uctCCDL; // + UCHAR uctCRCRL; // + UCHAR uctCRCWL; // + UCHAR uctCKE; // + UCHAR uctCKRSE; // + UCHAR uctCKRSX; // + UCHAR uctFAW32; // + UCHAR ucMR5lo; // + UCHAR ucMR5hi; // UCHAR ucTerminator; }ATOM_MEMORY_TIMING_FORMAT_V1; typedef struct _ATOM_MEMORY_TIMING_FORMAT_V2 { - ULONG ulClkRange; // memory clock in 10kHz unit, when target memory clock is below this clock, use this memory timing - USHORT usMRS; // mode register + ULONG ulClkRange; // memory clock in 10kHz unit, when target memory clock is below this clock, use this memory timing + USHORT usMRS; // mode register USHORT usEMRS; // extended mode register UCHAR ucCL; // CAS latency - UCHAR ucWL; // WRITE Latency + UCHAR ucWL; // WRITE Latency UCHAR uctRAS; // tRAS - UCHAR uctRC; // tRC + UCHAR uctRC; // tRC UCHAR uctRFC; // tRFC - UCHAR uctRCDR; // tRCDR + UCHAR uctRCDR; // tRCDR UCHAR uctRCDW; // tRCDW UCHAR uctRP; // tRP - UCHAR uctRRD; // tRRD + UCHAR uctRRD; // tRRD UCHAR uctWR; // tWR UCHAR uctWTR; // tWTR UCHAR uctPDIX; // tPDIX UCHAR uctFAW; // tFAW UCHAR uctAOND; // tAOND - UCHAR ucflag; // flag to control memory timing calculation. bit0= control EMRS2 Infineon + UCHAR ucflag; // flag to control memory timing calculation. bit0= control EMRS2 Infineon ////////////////////////////////////GDDR parameters/////////////////////////////////// - UCHAR uctCCDL; // - UCHAR uctCRCRL; // - UCHAR uctCRCWL; // - UCHAR uctCKE; // - UCHAR uctCKRSE; // - UCHAR uctCKRSX; // - UCHAR uctFAW32; // - UCHAR ucMR4lo; // - UCHAR ucMR4hi; // - UCHAR ucMR5lo; // - UCHAR ucMR5hi; // + UCHAR uctCCDL; // + UCHAR uctCRCRL; // + UCHAR uctCRCWL; // + UCHAR uctCKE; // + UCHAR uctCKRSE; // + UCHAR uctCKRSX; // + UCHAR uctFAW32; // + UCHAR ucMR4lo; // + UCHAR ucMR4hi; // + UCHAR ucMR5lo; // + UCHAR ucMR5hi; // UCHAR ucTerminator; - UCHAR ucReserved; + UCHAR ucReserved; }ATOM_MEMORY_TIMING_FORMAT_V2; typedef struct _ATOM_MEMORY_FORMAT @@ -6562,7 +6560,7 @@ typedef struct _ATOM_MEMORY_FORMAT UCHAR ucRank; // Number of Rank, in power of 2 UCHAR ucBurstSize; // burst size, 0= burst size=4 1= burst size=8 UCHAR ucDllDisBit; // position of DLL Enable/Disable bit in EMRS ( Extended Mode Register ) - UCHAR ucRefreshRateFactor; // memory refresh rate in unit of ms + UCHAR ucRefreshRateFactor; // memory refresh rate in unit of ms UCHAR ucDensity; // _8Mx32, _16Mx32, _16Mx16, _32Mx16 UCHAR ucPreamble; //[7:4] Write Preamble, [3:0] Read Preamble UCHAR ucMemAttrib; // Memory Device Addribute, like RDBI/WDBI etc @@ -6578,7 +6576,7 @@ typedef struct _ATOM_VRAM_MODULE_V3 USHORT usDefaultMVDDC; // board dependent parameter:Default Memory IO Voltage UCHAR ucExtMemoryID; // An external indicator (by hardcode, callback or pin) to tell what is the current memory module UCHAR ucChannelNum; // board dependent parameter:Number of channel; - UCHAR ucChannelSize; // board dependent parameter:32bit or 64bit + UCHAR ucChannelSize; // board dependent parameter:32bit or 64bit UCHAR ucVREFI; // board dependnt parameter: EXT or INT +160mv to -140mv UCHAR ucNPL_RT; // board dependent parameter:NPL round trip delay, used for calculate memory timing parameters UCHAR ucFlag; // To enable/disable functionalities based on memory type @@ -6621,7 +6619,7 @@ typedef struct _ATOM_VRAM_MODULE_V4 union{ USHORT usEMRS3Value; // EMRS3 Value is used for GDDR2 and GDDR4 memory type USHORT usDDR3_MR3; // Used for DDR3 memory - }; + }; UCHAR ucMemoryVenderID; // Predefined, If not predefined, vendor detection table gets executed UCHAR ucRefreshRateFactor; // [1:0]=RefreshFactor (00=8ms, 01=16ms, 10=32ms,11=64ms) UCHAR ucReserved2[2]; @@ -6717,13 +6715,13 @@ typedef struct _ATOM_VRAM_MODULE_V7 USHORT usSEQSettingOffset; UCHAR ucReserved; // Memory Module specific values - USHORT usEMRS2Value; // EMRS2/MR2 Value. + USHORT usEMRS2Value; // EMRS2/MR2 Value. USHORT usEMRS3Value; // EMRS3/MR3 Value. UCHAR ucMemoryVenderID; // [7:4] Revision, [3:0] Vendor code UCHAR ucRefreshRateFactor; // [1:0]=RefreshFactor (00=8ms, 01=16ms, 10=32ms,11=64ms) UCHAR ucFIFODepth; // FIFO depth can be detected during vendor detection, here is hardcoded per memory UCHAR ucCDR_Bandwidth; // [0:3]=Read CDR bandwidth, [4:7] - Write CDR Bandwidth - char strMemPNString[20]; // part number end with '0'. + char strMemPNString[20]; // part number end with '0'. }ATOM_VRAM_MODULE_V7; typedef struct _ATOM_VRAM_INFO_V2 @@ -6756,7 +6754,7 @@ typedef struct _ATOM_VRAM_INFO_V4 USHORT usRerseved; UCHAR ucMemDQ7_0ByteRemap; // DQ line byte remap, =0: Memory Data line BYTE0, =1: BYTE1, =2: BYTE2, =3: BYTE3 ULONG ulMemDQ7_0BitRemap; // each DQ line ( 7~0) use 3bits, like: DQ0=Bit[2:0], DQ1:[5:3], ... DQ7:[23:21] - UCHAR ucReservde[4]; + UCHAR ucReservde[4]; UCHAR ucNumOfVRAMModule; ATOM_VRAM_MODULE_V4 aVramInfo[ATOM_MAX_NUMBER_OF_VRAM_MODULE]; // just for allocation, real number of blocks is in ucNumOfVRAMModule; ATOM_INIT_REG_BLOCK asMemPatch; // for allocation @@ -6773,7 +6771,7 @@ typedef struct _ATOM_VRAM_INFO_HEADER_V2_1 UCHAR ucNumOfVRAMModule; // indicate number of VRAM module UCHAR ucMemoryClkPatchTblVer; // version of memory AC timing register list UCHAR ucVramModuleVer; // indicate ATOM_VRAM_MODUE version - UCHAR ucReserved; + UCHAR ucReserved; ATOM_VRAM_MODULE_V7 aVramInfo[ATOM_MAX_NUMBER_OF_VRAM_MODULE]; // just for allocation, real number of blocks is in ucNumOfVRAMModule; }ATOM_VRAM_INFO_HEADER_V2_1; @@ -6797,18 +6795,18 @@ typedef struct _ATOM_MEMORY_TRAINING_INFO typedef struct SW_I2C_CNTL_DATA_PARAMETERS { UCHAR ucControl; - UCHAR ucData; - UCHAR ucSatus; - UCHAR ucTemp; + UCHAR ucData; + UCHAR ucSatus; + UCHAR ucTemp; } SW_I2C_CNTL_DATA_PARAMETERS; #define SW_I2C_CNTL_DATA_PS_ALLOCATION SW_I2C_CNTL_DATA_PARAMETERS typedef struct _SW_I2C_IO_DATA_PARAMETERS -{ +{ USHORT GPIO_Info; - UCHAR ucAct; - UCHAR ucData; + UCHAR ucAct; + UCHAR ucData; } SW_I2C_IO_DATA_PARAMETERS; #define SW_I2C_IO_DATA_PS_ALLOCATION SW_I2C_IO_DATA_PARAMETERS @@ -6842,8 +6840,8 @@ typedef struct _SW_I2C_IO_DATA_PARAMETERS typedef struct _PTR_32_BIT_STRUCTURE { - USHORT Offset16; - USHORT Segment16; + USHORT Offset16; + USHORT Segment16; } PTR_32_BIT_STRUCTURE; typedef union _PTR_32_BIT_UNION @@ -6963,7 +6961,7 @@ typedef struct _VESA_MODE_INFO_BLOCK #define ATOM_BIOS_FUNCTION_SHORT_QUERY1 0x04 #define ATOM_BIOS_FUNCTION_SHORT_QUERY2 0x05 #define ATOM_BIOS_FUNCTION_SHORT_QUERY3 0x06 -#define ATOM_BIOS_FUNCTION_GET_DDC 0x0B +#define ATOM_BIOS_FUNCTION_GET_DDC 0x0B #define ATOM_BIOS_FUNCTION_ASIC_DSTATE 0x0E #define ATOM_BIOS_FUNCTION_DEBUG_PLAY 0x0F #define ATOM_BIOS_FUNCTION_STV_STD 0x16 @@ -6973,28 +6971,28 @@ typedef struct _VESA_MODE_INFO_BLOCK #define ATOM_BIOS_FUNCTION_PANEL_CONTROL 0x82 #define ATOM_BIOS_FUNCTION_OLD_DEVICE_DET 0x83 #define ATOM_BIOS_FUNCTION_OLD_DEVICE_SWITCH 0x84 -#define ATOM_BIOS_FUNCTION_HW_ICON 0x8A +#define ATOM_BIOS_FUNCTION_HW_ICON 0x8A #define ATOM_BIOS_FUNCTION_SET_CMOS 0x8B #define SUB_FUNCTION_UPDATE_DISPLAY_INFO 0x8000 // Sub function 80 #define SUB_FUNCTION_UPDATE_EXPANSION_INFO 0x8100 // Sub function 80 #define ATOM_BIOS_FUNCTION_DISPLAY_INFO 0x8D #define ATOM_BIOS_FUNCTION_DEVICE_ON_OFF 0x8E -#define ATOM_BIOS_FUNCTION_VIDEO_STATE 0x8F -#define ATOM_SUB_FUNCTION_GET_CRITICAL_STATE 0x0300 // Sub function 03 +#define ATOM_BIOS_FUNCTION_VIDEO_STATE 0x8F +#define ATOM_SUB_FUNCTION_GET_CRITICAL_STATE 0x0300 // Sub function 03 #define ATOM_SUB_FUNCTION_GET_LIDSTATE 0x0700 // Sub function 7 #define ATOM_SUB_FUNCTION_THERMAL_STATE_NOTICE 0x1400 // Notify caller the current thermal state #define ATOM_SUB_FUNCTION_CRITICAL_STATE_NOTICE 0x8300 // Notify caller the current critical state #define ATOM_SUB_FUNCTION_SET_LIDSTATE 0x8500 // Sub function 85 #define ATOM_SUB_FUNCTION_GET_REQ_DISPLAY_FROM_SBIOS_MODE 0x8900// Sub function 89 #define ATOM_SUB_FUNCTION_INFORM_ADC_SUPPORT 0x9400 // Notify caller that ADC is supported - -#define ATOM_BIOS_FUNCTION_VESA_DPMS 0x4F10 // Set DPMS -#define ATOM_SUB_FUNCTION_SET_DPMS 0x0001 // BL: Sub function 01 -#define ATOM_SUB_FUNCTION_GET_DPMS 0x0002 // BL: Sub function 02 -#define ATOM_PARAMETER_VESA_DPMS_ON 0x0000 // BH Parameter for DPMS ON. -#define ATOM_PARAMETER_VESA_DPMS_STANDBY 0x0100 // BH Parameter for DPMS STANDBY + +#define ATOM_BIOS_FUNCTION_VESA_DPMS 0x4F10 // Set DPMS +#define ATOM_SUB_FUNCTION_SET_DPMS 0x0001 // BL: Sub function 01 +#define ATOM_SUB_FUNCTION_GET_DPMS 0x0002 // BL: Sub function 02 +#define ATOM_PARAMETER_VESA_DPMS_ON 0x0000 // BH Parameter for DPMS ON. +#define ATOM_PARAMETER_VESA_DPMS_STANDBY 0x0100 // BH Parameter for DPMS STANDBY #define ATOM_PARAMETER_VESA_DPMS_SUSPEND 0x0200 // BH Parameter for DPMS SUSPEND #define ATOM_PARAMETER_VESA_DPMS_OFF 0x0400 // BH Parameter for DPMS OFF #define ATOM_PARAMETER_VESA_DPMS_REDUCE_ON 0x0800 // BH Parameter for DPMS REDUCE ON (NOT SUPPORTED) @@ -7037,7 +7035,7 @@ typedef struct _ASIC_ENCODER_INFO typedef struct _ATOM_DISP_OUT_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; USHORT ptrTransmitterInfo; USHORT ptrEncoderInfo; ASIC_TRANSMITTER_INFO asTransmitterInfo[1]; @@ -7046,17 +7044,17 @@ typedef struct _ATOM_DISP_OUT_INFO typedef struct _ATOM_DISP_OUT_INFO_V2 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; USHORT ptrTransmitterInfo; USHORT ptrEncoderInfo; - USHORT ptrMainCallParserFar; // direct address of main parser call in VBIOS binary. + USHORT ptrMainCallParserFar; // direct address of main parser call in VBIOS binary. ASIC_TRANSMITTER_INFO asTransmitterInfo[1]; ASIC_ENCODER_INFO asEncoderInfo[1]; }ATOM_DISP_OUT_INFO_V2; typedef struct _ATOM_DISP_CLOCK_ID { - UCHAR ucPpllId; + UCHAR ucPpllId; UCHAR ucPpllAttribute; }ATOM_DISP_CLOCK_ID; @@ -7080,12 +7078,12 @@ typedef struct _ASIC_TRANSMITTER_INFO_V2 typedef struct _ATOM_DISP_OUT_INFO_V3 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; USHORT ptrTransmitterInfo; USHORT ptrEncoderInfo; - USHORT ptrMainCallParserFar; // direct address of main parser call in VBIOS binary. + USHORT ptrMainCallParserFar; // direct address of main parser call in VBIOS binary. USHORT usReserved; - UCHAR ucDCERevision; + UCHAR ucDCERevision; UCHAR ucMaxDispEngineNum; UCHAR ucMaxActiveDispEngineNum; UCHAR ucMaxPPLLNum; @@ -7108,7 +7106,7 @@ typedef enum CORE_REF_CLK_SOURCE{ // DispDevicePriorityInfo typedef struct _ATOM_DISPLAY_DEVICE_PRIORITY_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; USHORT asDevicePriority[16]; }ATOM_DISPLAY_DEVICE_PRIORITY_INFO; @@ -7149,7 +7147,7 @@ typedef struct _PROCESS_AUX_CHANNEL_TRANSACTION_PARAMETERS_V2 typedef struct _DP_ENCODER_SERVICE_PARAMETERS { USHORT ucLinkClock; - union + union { UCHAR ucConfig; // for DP training command UCHAR ucI2cId; // use for GET_SINK_TYPE command @@ -7187,7 +7185,7 @@ typedef struct _DP_ENCODER_SERVICE_PARAMETERS_V2 USHORT usExtEncoderObjId; // External Encoder Object Id, output parameter only, use when ucAction = DP_SERVICE_V2_ACTION_DET_EXT_CONNECTION UCHAR ucAuxId; UCHAR ucAction; - UCHAR ucSinkType; // Iput and Output parameters. + UCHAR ucSinkType; // Iput and Output parameters. UCHAR ucHPDId; // Input parameter, used when ucAction = DP_SERVICE_V2_ACTION_DET_EXT_CONNECTION UCHAR ucReserved[2]; }DP_ENCODER_SERVICE_PARAMETERS_V2; @@ -7204,7 +7202,7 @@ typedef struct _DP_ENCODER_SERVICE_PS_ALLOCATION_V2 // DP_TRAINING_TABLE -#define DPCD_SET_LINKRATE_LANENUM_PATTERN1_TBL_ADDR ATOM_DP_TRAINING_TBL_ADDR +#define DPCD_SET_LINKRATE_LANENUM_PATTERN1_TBL_ADDR ATOM_DP_TRAINING_TBL_ADDR #define DPCD_SET_SS_CNTL_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 8 ) #define DPCD_SET_LANE_VSWING_PREEMP_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 16 ) #define DPCD_SET_TRAINING_PATTERN0_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 24 ) @@ -7215,7 +7213,7 @@ typedef struct _DP_ENCODER_SERVICE_PS_ALLOCATION_V2 #define DP_I2C_AUX_DDC_WRITE_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 64) #define DP_I2C_AUX_DDC_READ_START_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 72) #define DP_I2C_AUX_DDC_READ_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 76) -#define DP_I2C_AUX_DDC_WRITE_END_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 80) +#define DP_I2C_AUX_DDC_WRITE_END_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 80) #define DP_I2C_AUX_DDC_READ_END_TBL_ADDR (ATOM_DP_TRAINING_TBL_ADDR + 84) typedef struct _PROCESS_I2C_CHANNEL_TRANSACTION_PARAMETERS @@ -7227,7 +7225,7 @@ typedef struct _PROCESS_I2C_CHANNEL_TRANSACTION_PARAMETERS UCHAR ucStatus; }; USHORT lpI2CDataOut; - UCHAR ucFlag; + UCHAR ucFlag; UCHAR ucTransBytes; UCHAR ucSlaveAddr; UCHAR ucLineNumber; @@ -7240,17 +7238,17 @@ typedef struct _PROCESS_I2C_CHANNEL_TRANSACTION_PARAMETERS #define HW_I2C_READ 0 #define I2C_2BYTE_ADDR 0x02 -/****************************************************************************/ +/****************************************************************************/ // Structures used by HW_Misc_OperationTable -/****************************************************************************/ -typedef struct _ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1 +/****************************************************************************/ +typedef struct _ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1 { UCHAR ucCmd; // Input: To tell which action to take UCHAR ucReserved[3]; ULONG ulReserved; -}ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1; +}ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1; -typedef struct _ATOM_HW_MISC_OPERATION_OUTPUT_PARAMETER_V1_1 +typedef struct _ATOM_HW_MISC_OPERATION_OUTPUT_PARAMETER_V1_1 { UCHAR ucReturnCode; // Output: Return value base on action was taken UCHAR ucReserved[3]; @@ -7260,7 +7258,7 @@ typedef struct _ATOM_HW_MISC_OPERATION_OUTPUT_PARAMETER_V1_1 // Actions code #define ATOM_GET_SDI_SUPPORT 0xF0 -// Return code +// Return code #define ATOM_UNKNOWN_CMD 0 #define ATOM_FEATURE_NOT_SUPPORTED 1 #define ATOM_FEATURE_SUPPORTED 2 @@ -7268,15 +7266,15 @@ typedef struct _ATOM_HW_MISC_OPERATION_OUTPUT_PARAMETER_V1_1 typedef struct _ATOM_HW_MISC_OPERATION_PS_ALLOCATION { ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1 sInput_Output; - PROCESS_I2C_CHANNEL_TRANSACTION_PARAMETERS sReserved; + PROCESS_I2C_CHANNEL_TRANSACTION_PARAMETERS sReserved; }ATOM_HW_MISC_OPERATION_PS_ALLOCATION; -/****************************************************************************/ +/****************************************************************************/ typedef struct _SET_HWBLOCK_INSTANCE_PARAMETER_V2 { UCHAR ucHWBlkInst; // HW block instance, 0, 1, 2, ... - UCHAR ucReserved[3]; + UCHAR ucReserved[3]; }SET_HWBLOCK_INSTANCE_PARAMETER_V2; #define HWBLKINST_INSTANCE_MASK 0x07 @@ -7293,24 +7291,24 @@ typedef struct _SET_HWBLOCK_INSTANCE_PARAMETER_V2 #define SELECT_CRTC_PIXEL_RATE 7 #define SELECT_VGA_BLK 8 -// DIGTransmitterInfoTable structure used to program UNIPHY settings -typedef struct _DIG_TRANSMITTER_INFO_HEADER_V3_1{ - ATOM_COMMON_TABLE_HEADER sHeader; - USHORT usDPVsPreEmphSettingOffset; // offset of PHY_ANALOG_SETTING_INFO * with DP Voltage Swing and Pre-Emphasis for each Link clock - USHORT usPhyAnalogRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with None-DP mode Analog Setting's register Info +// DIGTransmitterInfoTable structure used to program UNIPHY settings +typedef struct _DIG_TRANSMITTER_INFO_HEADER_V3_1{ + ATOM_COMMON_TABLE_HEADER sHeader; + USHORT usDPVsPreEmphSettingOffset; // offset of PHY_ANALOG_SETTING_INFO * with DP Voltage Swing and Pre-Emphasis for each Link clock + USHORT usPhyAnalogRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with None-DP mode Analog Setting's register Info USHORT usPhyAnalogSettingOffset; // offset of CLOCK_CONDITION_SETTING_ENTRY* with None-DP mode Analog Setting for each link clock range - USHORT usPhyPllRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with Phy Pll register Info + USHORT usPhyPllRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with Phy Pll register Info USHORT usPhyPllSettingOffset; // offset of CLOCK_CONDITION_SETTING_ENTRY* with Phy Pll Settings }DIG_TRANSMITTER_INFO_HEADER_V3_1; -typedef struct _DIG_TRANSMITTER_INFO_HEADER_V3_2{ - ATOM_COMMON_TABLE_HEADER sHeader; - USHORT usDPVsPreEmphSettingOffset; // offset of PHY_ANALOG_SETTING_INFO * with DP Voltage Swing and Pre-Emphasis for each Link clock - USHORT usPhyAnalogRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with None-DP mode Analog Setting's register Info +typedef struct _DIG_TRANSMITTER_INFO_HEADER_V3_2{ + ATOM_COMMON_TABLE_HEADER sHeader; + USHORT usDPVsPreEmphSettingOffset; // offset of PHY_ANALOG_SETTING_INFO * with DP Voltage Swing and Pre-Emphasis for each Link clock + USHORT usPhyAnalogRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with None-DP mode Analog Setting's register Info USHORT usPhyAnalogSettingOffset; // offset of CLOCK_CONDITION_SETTING_ENTRY* with None-DP mode Analog Setting for each link clock range - USHORT usPhyPllRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with Phy Pll register Info + USHORT usPhyPllRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with Phy Pll register Info USHORT usPhyPllSettingOffset; // offset of CLOCK_CONDITION_SETTING_ENTRY* with Phy Pll Settings - USHORT usDPSSRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with Phy SS Pll register Info + USHORT usDPSSRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with Phy SS Pll register Info USHORT usDPSSSettingOffset; // offset of CLOCK_CONDITION_SETTING_ENTRY* with Phy SS Pll Settings }DIG_TRANSMITTER_INFO_HEADER_V3_2; @@ -7371,9 +7369,9 @@ typedef struct _PHY_ANALOG_SETTING_INFO_V2{ typedef struct _GFX_HAVESTING_PARAMETERS { UCHAR ucGfxBlkId; //GFX blk id to be harvested, like CU, RB or PRIM - UCHAR ucReserved; //reserved + UCHAR ucReserved; //reserved UCHAR ucActiveUnitNumPerSH; //requested active CU/RB/PRIM number per shader array - UCHAR ucMaxUnitNumPerSH; //max CU/RB/PRIM number per shader array + UCHAR ucMaxUnitNumPerSH; //max CU/RB/PRIM number per shader array } GFX_HAVESTING_PARAMETERS; //ucGfxBlkId @@ -7381,7 +7379,7 @@ typedef struct _GFX_HAVESTING_PARAMETERS { #define GFX_HARVESTING_RB_ID 1 #define GFX_HARVESTING_PRIM_ID 2 -/****************************************************************************/ +/****************************************************************************/ //Portion VI: Definitinos for vbios MC scratch registers that driver used /****************************************************************************/ @@ -7402,7 +7400,7 @@ typedef struct _GFX_HAVESTING_PARAMETERS { #define ATOM_MEM_TYPE_HBM_STRING "HBM" #define ATOM_MEM_TYPE_DDR3_STRING "DDR3" -/****************************************************************************/ +/****************************************************************************/ //Portion VI: Definitinos being oboselete /****************************************************************************/ @@ -7410,15 +7408,15 @@ typedef struct _GFX_HAVESTING_PARAMETERS { //Remove the definitions below when driver is ready! typedef struct _ATOM_DAC_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; USHORT usMaxFrequency; // in 10kHz unit USHORT usReserved; }ATOM_DAC_INFO; -typedef struct _COMPASSIONATE_DATA +typedef struct _COMPASSIONATE_DATA { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; //============================== DAC1 portion UCHAR ucDAC1_BG_Adjustment; @@ -7448,7 +7446,7 @@ typedef struct _COMPASSIONATE_DATA /****************************Supported Device Info Table Definitions**********************/ // ucConnectInfo: // [7:4] - connector type -// = 1 - VGA connector +// = 1 - VGA connector // = 2 - DVI-I // = 3 - DVI-D // = 4 - DVI-A @@ -7467,7 +7465,7 @@ typedef struct _COMPASSIONATE_DATA // = 2 - DACB // = 3 - External DAC // Others=TBD -// +// typedef struct _ATOM_CONNECTOR_INFO { @@ -7494,7 +7492,7 @@ typedef struct _ATOM_CONNECTOR_INFO_I2C typedef struct _ATOM_SUPPORTED_DEVICES_INFO -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; USHORT usDeviceSupport; ATOM_CONNECTOR_INFO_I2C asConnInfo[ATOM_MAX_SUPPORTED_DEVICE_INFO]; @@ -7508,7 +7506,7 @@ typedef struct _ATOM_CONNECTOR_INC_SRC_BITMAP }ATOM_CONNECTOR_INC_SRC_BITMAP; typedef struct _ATOM_SUPPORTED_DEVICES_INFO_2 -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; USHORT usDeviceSupport; ATOM_CONNECTOR_INFO_I2C asConnInfo[ATOM_MAX_SUPPORTED_DEVICE_INFO_2]; @@ -7516,7 +7514,7 @@ typedef struct _ATOM_SUPPORTED_DEVICES_INFO_2 }ATOM_SUPPORTED_DEVICES_INFO_2; typedef struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 -{ +{ ATOM_COMMON_TABLE_HEADER sHeader; USHORT usDeviceSupport; ATOM_CONNECTOR_INFO_I2C asConnInfo[ATOM_MAX_SUPPORTED_DEVICE]; @@ -7534,14 +7532,14 @@ typedef struct _ATOM_MISC_CONTROL_INFO UCHAR ucPLL_DutyCycle; // PLL duty cycle control UCHAR ucPLL_VCO_Gain; // PLL VCO gain control UCHAR ucPLL_VoltageSwing; // PLL driver voltage swing control -}ATOM_MISC_CONTROL_INFO; +}ATOM_MISC_CONTROL_INFO; #define ATOM_MAX_MISC_INFO 4 typedef struct _ATOM_TMDS_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; USHORT usMaxFrequency; // in 10Khz ATOM_MISC_CONTROL_INFO asMiscInfo[ATOM_MAX_MISC_INFO]; }ATOM_TMDS_INFO; @@ -7549,14 +7547,14 @@ typedef struct _ATOM_TMDS_INFO typedef struct _ATOM_ENCODER_ANALOG_ATTRIBUTE { - UCHAR ucTVStandard; //Same as TV standards defined above, + UCHAR ucTVStandard; //Same as TV standards defined above, UCHAR ucPadding[1]; }ATOM_ENCODER_ANALOG_ATTRIBUTE; typedef struct _ATOM_ENCODER_DIGITAL_ATTRIBUTE { UCHAR ucAttribute; //Same as other digital encoder attributes defined above - UCHAR ucPadding[1]; + UCHAR ucPadding[1]; }ATOM_ENCODER_DIGITAL_ATTRIBUTE; typedef union _ATOM_ENCODER_ATTRIBUTE @@ -7568,15 +7566,15 @@ typedef union _ATOM_ENCODER_ATTRIBUTE typedef struct _DVO_ENCODER_CONTROL_PARAMETERS { - USHORT usPixelClock; - USHORT usEncoderID; - UCHAR ucDeviceType; //Use ATOM_DEVICE_xxx1_Index to indicate device type only. + USHORT usPixelClock; + USHORT usEncoderID; + UCHAR ucDeviceType; //Use ATOM_DEVICE_xxx1_Index to indicate device type only. UCHAR ucAction; //ATOM_ENABLE/ATOM_DISABLE/ATOM_HPD_INIT - ATOM_ENCODER_ATTRIBUTE usDevAttr; + ATOM_ENCODER_ATTRIBUTE usDevAttr; }DVO_ENCODER_CONTROL_PARAMETERS; typedef struct _DVO_ENCODER_CONTROL_PS_ALLOCATION -{ +{ DVO_ENCODER_CONTROL_PARAMETERS sDVOEncoder; WRITE_ONE_BYTE_HW_I2C_DATA_PS_ALLOCATION sReserved; //Caller doesn't need to init this portion }DVO_ENCODER_CONTROL_PS_ALLOCATION; @@ -7589,25 +7587,25 @@ typedef struct _DVO_ENCODER_CONTROL_PS_ALLOCATION #define ATOM_XTMDS_SUPPORTED_DUALLINK 0x00000002 #define ATOM_XTMDS_MVPU_FPGA 0x00000004 - + typedef struct _ATOM_XTMDS_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; - USHORT usSingleLinkMaxFrequency; + ATOM_COMMON_TABLE_HEADER sHeader; + USHORT usSingleLinkMaxFrequency; ATOM_I2C_ID_CONFIG_ACCESS sucI2cId; //Point the ID on which I2C is used to control external chip - UCHAR ucXtransimitterID; + UCHAR ucXtransimitterID; UCHAR ucSupportedLink; // Bit field, bit0=1, single link supported;bit1=1,dual link supported - UCHAR ucSequnceAlterID; // Even with the same external TMDS asic, it's possible that the program seqence alters - // due to design. This ID is used to alert driver that the sequence is not "standard"! + UCHAR ucSequnceAlterID; // Even with the same external TMDS asic, it's possible that the program seqence alters + // due to design. This ID is used to alert driver that the sequence is not "standard"! UCHAR ucMasterAddress; // Address to control Master xTMDS Chip UCHAR ucSlaveAddress; // Address to control Slave xTMDS Chip }ATOM_XTMDS_INFO; typedef struct _DFP_DPMS_STATUS_CHANGE_PARAMETERS -{ +{ UCHAR ucEnable; // ATOM_ENABLE=On or ATOM_DISABLE=Off UCHAR ucDevice; // ATOM_DEVICE_DFP1_INDEX.... - UCHAR ucPadding[2]; + UCHAR ucPadding[2]; }DFP_DPMS_STATUS_CHANGE_PARAMETERS; /****************************Legacy Power Play Table Definitions **********************/ @@ -7624,8 +7622,8 @@ typedef struct _DFP_DPMS_STATUS_CHANGE_PARAMETERS #define ATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN 0x00000020L #define ATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN 0x00000040L -#define ATOM_PM_MISCINFO_PROGRAM_VOLTAGE 0x00000080L //When this bit set, ucVoltageDropIndex is not an index for GPIO pin, but a voltage ID that SW needs program - +#define ATOM_PM_MISCINFO_PROGRAM_VOLTAGE 0x00000080L //When this bit set, ucVoltageDropIndex is not an index for GPIO pin, but a voltage ID that SW needs program + #define ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN 0x00000100L #define ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN 0x00000200L #define ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN 0x00000400L @@ -7635,22 +7633,22 @@ typedef struct _DFP_DPMS_STATUS_CHANGE_PARAMETERS #define ATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE 0x00004000L #define ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE 0x00008000L -#define ATOM_PM_MISCINFO_OVER_CLOCK_MODE 0x00010000L +#define ATOM_PM_MISCINFO_OVER_CLOCK_MODE 0x00010000L #define ATOM_PM_MISCINFO_OVER_DRIVE_MODE 0x00020000L #define ATOM_PM_MISCINFO_POWER_SAVING_MODE 0x00040000L #define ATOM_PM_MISCINFO_THERMAL_DIODE_MODE 0x00080000L #define ATOM_PM_MISCINFO_FRAME_MODULATION_MASK 0x00300000L //0-FM Disable, 1-2 level FM, 2-4 level FM, 3-Reserved -#define ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT 20 +#define ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT 20 #define ATOM_PM_MISCINFO_DYN_CLK_3D_IDLE 0x00400000L #define ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2 0x00800000L #define ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4 0x01000000L -#define ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN 0x02000000L //When set, Dynamic +#define ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN 0x02000000L //When set, Dynamic #define ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN 0x04000000L //When set, Dynamic #define ATOM_PM_MISCINFO_3D_ACCELERATION_EN 0x08000000L //When set, This mode is for acceleated 3D mode -#define ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK 0x70000000L //1-Optimal Battery Life Group, 2-High Battery, 3-Balanced, 4-High Performance, 5- Optimal Performance (Default state with Default clocks) +#define ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK 0x70000000L //1-Optimal Battery Life Group, 2-High Battery, 3-Balanced, 4-High Performance, 5- Optimal Performance (Default state with Default clocks) #define ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT 28 #define ATOM_PM_MISCINFO_ENABLE_BACK_BIAS 0x80000000L @@ -7660,11 +7658,11 @@ typedef struct _DFP_DPMS_STATUS_CHANGE_PARAMETERS #define ATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO 0x00000008L #define ATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE 0x00000010L #define ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN 0x00000020L -#define ATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE 0x00000040L //If this bit is set in multi-pp mode, then driver will pack up one with the minior power consumption. +#define ATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE 0x00000040L //If this bit is set in multi-pp mode, then driver will pack up one with the minior power consumption. //If it's not set in any pp mode, driver will use its default logic to pick a pp mode in video playback #define ATOM_PM_MISCINFO2_NOT_VALID_ON_DC 0x00000080L #define ATOM_PM_MISCINFO2_STUTTER_MODE_EN 0x00000100L -#define ATOM_PM_MISCINFO2_UVD_SUPPORT_MODE 0x00000200L +#define ATOM_PM_MISCINFO2_UVD_SUPPORT_MODE 0x00000200L //ucTableFormatRevision=1 //ucTableContentRevision=1 @@ -7687,8 +7685,8 @@ typedef struct _ATOM_POWERMODE_INFO typedef struct _ATOM_POWERMODE_INFO_V2 { ULONG ulMiscInfo; //The power level should be arranged in ascending order - ULONG ulMiscInfo2; - ULONG ulEngineClock; + ULONG ulMiscInfo2; + ULONG ulEngineClock; ULONG ulMemoryClock; UCHAR ucVoltageDropIndex; // index to GPIO table UCHAR ucSelectedPanel_RefreshRate;// panel refresh rate @@ -7702,8 +7700,8 @@ typedef struct _ATOM_POWERMODE_INFO_V2 typedef struct _ATOM_POWERMODE_INFO_V3 { ULONG ulMiscInfo; //The power level should be arranged in ascending order - ULONG ulMiscInfo2; - ULONG ulEngineClock; + ULONG ulMiscInfo2; + ULONG ulEngineClock; ULONG ulMemoryClock; UCHAR ucVoltageDropIndex; // index to Core (VDDC) votage table UCHAR ucSelectedPanel_RefreshRate;// panel refresh rate @@ -7730,7 +7728,7 @@ typedef struct _ATOM_POWERMODE_INFO_V3 typedef struct _ATOM_POWERPLAY_INFO { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; UCHAR ucOverdriveThermalController; UCHAR ucOverdriveI2cLine; UCHAR ucOverdriveIntBitmap; @@ -7742,7 +7740,7 @@ typedef struct _ATOM_POWERPLAY_INFO typedef struct _ATOM_POWERPLAY_INFO_V2 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; UCHAR ucOverdriveThermalController; UCHAR ucOverdriveI2cLine; UCHAR ucOverdriveIntBitmap; @@ -7751,10 +7749,10 @@ typedef struct _ATOM_POWERPLAY_INFO_V2 UCHAR ucNumOfPowerModeEntries; ATOM_POWERMODE_INFO_V2 asPowerPlayInfo[ATOM_MAX_NUMBEROF_POWER_BLOCK]; }ATOM_POWERPLAY_INFO_V2; - + typedef struct _ATOM_POWERPLAY_INFO_V3 { - ATOM_COMMON_TABLE_HEADER sHeader; + ATOM_COMMON_TABLE_HEADER sHeader; UCHAR ucOverdriveThermalController; UCHAR ucOverdriveI2cLine; UCHAR ucOverdriveIntBitmap; @@ -7765,14 +7763,14 @@ typedef struct _ATOM_POWERPLAY_INFO_V3 }ATOM_POWERPLAY_INFO_V3; -// Following definitions are for compatibility issue in different SW components. +// Following definitions are for compatibility issue in different SW components. #define ATOM_MASTER_DATA_TABLE_REVISION 0x01 -#define Object_Info Object_Header +#define Object_Info Object_Header #define AdjustARB_SEQ MC_InitParameter #define VRAM_GPIO_DetectionInfo VoltageObjectInfo -#define ASIC_VDDCI_Info ASIC_ProfilingInfo +#define ASIC_VDDCI_Info ASIC_ProfilingInfo #define ASIC_MVDDQ_Info MemoryTrainingInfo -#define SS_Info PPLL_SS_Info +#define SS_Info PPLL_SS_Info #define ASIC_MVDDC_Info ASIC_InternalSS_Info #define DispDevicePriorityInfo SaveRestoreInfo #define DispOutInfo TV_VideoMode @@ -7796,7 +7794,7 @@ typedef struct _ATOM_POWERPLAY_INFO_V3 #define ATOM_DEVICE_DFP1I_INDEX ATOM_DEVICE_DFP1_INDEX #define ATOM_DEVICE_DFP1X_INDEX ATOM_DEVICE_DFP2_INDEX - + #define ATOM_DEVICE_DFP2I_INDEX 0x00000009 #define ATOM_DEVICE_DFP2I_SUPPORT (0x1L << ATOM_DEVICE_DFP2I_INDEX) @@ -7814,7 +7812,7 @@ typedef struct _ATOM_POWERPLAY_INFO_V3 #define ATOM_S3_DFP2I_ACTIVEb1 0x02 -#define ATOM_S3_DFP1I_ACTIVE ATOM_S3_DFP1_ACTIVE +#define ATOM_S3_DFP1I_ACTIVE ATOM_S3_DFP1_ACTIVE #define ATOM_S3_DFP1X_ACTIVE ATOM_S3_DFP2_ACTIVE #define ATOM_S3_DFP2I_ACTIVE 0x00000200L @@ -7833,14 +7831,14 @@ typedef struct _ATOM_POWERPLAY_INFO_V3 #define ATOM_S6_ACC_REQ_DFP2Ib3 0x02 #define ATOM_S6_ACC_REQ_DFP2I 0x02000000L -#define TMDS1XEncoderControl DVOEncoderControl +#define TMDS1XEncoderControl DVOEncoderControl #define DFP1XOutputControl DVOOutputControl #define ExternalDFPOutputControl DFP1XOutputControl #define EnableExternalTMDS_Encoder TMDS1XEncoderControl #define DFP1IOutputControl TMDSAOutputControl -#define DFP2IOutputControl LVTMAOutputControl +#define DFP2IOutputControl LVTMAOutputControl #define DAC1_ENCODER_CONTROL_PARAMETERS DAC_ENCODER_CONTROL_PARAMETERS #define DAC1_ENCODER_CONTROL_PS_ALLOCATION DAC_ENCODER_CONTROL_PS_ALLOCATION @@ -7849,7 +7847,7 @@ typedef struct _ATOM_POWERPLAY_INFO_V3 #define DAC2_ENCODER_CONTROL_PS_ALLOCATION DAC_ENCODER_CONTROL_PS_ALLOCATION #define ucDac1Standard ucDacStandard -#define ucDac2Standard ucDacStandard +#define ucDac2Standard ucDacStandard #define TMDS1EncoderControl TMDSAEncoderControl #define TMDS2EncoderControl LVTMAEncoderControl @@ -7861,7 +7859,7 @@ typedef struct _ATOM_POWERPLAY_INFO_V3 //These two lines will be removed for sure in a few days, will follow up with Michael V. #define EnableLVDS_SS EnableSpreadSpectrumOnPPLL -#define ENABLE_LVDS_SS_PARAMETERS_V3 ENABLE_SPREAD_SPECTRUM_ON_PPLL +#define ENABLE_LVDS_SS_PARAMETERS_V3 ENABLE_SPREAD_SPECTRUM_ON_PPLL //#define ATOM_S2_CRT1_DPMS_STATE 0x00010000L //#define ATOM_S2_LCD1_DPMS_STATE ATOM_S2_CRT1_DPMS_STATE diff --git a/sys/dev/pci/drm/radeon/ci_dpm.c b/sys/dev/pci/drm/radeon/ci_dpm.c index 8ef25ab30..b8f4dac68 100644 --- a/sys/dev/pci/drm/radeon/ci_dpm.c +++ b/sys/dev/pci/drm/radeon/ci_dpm.c @@ -5517,6 +5517,7 @@ static int ci_parse_power_table(struct radeon_device *rdev) u8 frev, crev; u8 *power_state_offset; struct ci_ps *ps; + int ret; if (!atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset)) @@ -5546,11 +5547,15 @@ static int ci_parse_power_table(struct radeon_device *rdev) non_clock_array_index = power_state->v2.nonClockInfoIndex; non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) &non_clock_info_array->nonClockInfo[non_clock_array_index]; - if (!rdev->pm.power_state[i].clock_info) - return -EINVAL; + if (!rdev->pm.power_state[i].clock_info) { + ret = -EINVAL; + goto err_free_ps; + } ps = kzalloc(sizeof(struct ci_ps), GFP_KERNEL); - if (ps == NULL) - return -ENOMEM; + if (ps == NULL) { + ret = -ENOMEM; + goto err_free_ps; + } rdev->pm.dpm.ps[i].ps_priv = ps; ci_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i], non_clock_info, @@ -5590,6 +5595,12 @@ static int ci_parse_power_table(struct radeon_device *rdev) } return 0; + +err_free_ps: + for (i = 0; i < rdev->pm.dpm.num_ps; i++) + kfree(rdev->pm.dpm.ps[i].ps_priv); + kfree(rdev->pm.dpm.ps); + return ret; } static int ci_get_vbios_boot_values(struct radeon_device *rdev, @@ -5678,25 +5689,26 @@ int ci_dpm_init(struct radeon_device *rdev) ret = ci_get_vbios_boot_values(rdev, &pi->vbios_boot_state); if (ret) { - ci_dpm_fini(rdev); + kfree(rdev->pm.dpm.priv); return ret; } ret = r600_get_platform_caps(rdev); if (ret) { - ci_dpm_fini(rdev); + kfree(rdev->pm.dpm.priv); return ret; } ret = r600_parse_extended_power_table(rdev); if (ret) { - ci_dpm_fini(rdev); + kfree(rdev->pm.dpm.priv); return ret; } ret = ci_parse_power_table(rdev); if (ret) { - ci_dpm_fini(rdev); + kfree(rdev->pm.dpm.priv); + r600_free_extended_power_table(rdev); return ret; } diff --git a/sys/dev/pci/drm/radeon/cypress_dpm.c b/sys/dev/pci/drm/radeon/cypress_dpm.c index fdddbbaec..72a0768df 100644 --- a/sys/dev/pci/drm/radeon/cypress_dpm.c +++ b/sys/dev/pci/drm/radeon/cypress_dpm.c @@ -557,8 +557,12 @@ static int cypress_populate_mclk_value(struct radeon_device *rdev, ASIC_INTERNAL_MEMORY_SS, vco_freq)) { u32 reference_clock = rdev->clock.mpll.reference_freq; u32 decoded_ref = rv740_get_decoded_reference_divider(dividers.ref_div); - u32 clk_s = reference_clock * 5 / (decoded_ref * ss.rate); - u32 clk_v = ss.percentage * + u32 clk_s, clk_v; + + if (!decoded_ref) + return -EINVAL; + clk_s = reference_clock * 5 / (decoded_ref * ss.rate); + clk_v = ss.percentage * (0x4000 * dividers.whole_fb_div + 0x800 * dividers.frac_fb_div) / (clk_s * 625); mpll_ss1 &= ~CLKV_MASK; diff --git a/sys/dev/pci/drm/radeon/evergreen.c b/sys/dev/pci/drm/radeon/evergreen.c index 42507f7c2..452569764 100644 --- a/sys/dev/pci/drm/radeon/evergreen.c +++ b/sys/dev/pci/drm/radeon/evergreen.c @@ -2941,7 +2941,7 @@ void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) if (ring->rptr_save_reg) { next_rptr = ring->wptr + 3 + 4; radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); - radeon_ring_write(ring, ((ring->rptr_save_reg - + radeon_ring_write(ring, ((ring->rptr_save_reg - PACKET3_SET_CONFIG_REG_START) >> 2)); radeon_ring_write(ring, next_rptr); } else if (rdev->wb.enabled) { diff --git a/sys/dev/pci/drm/radeon/ni.c b/sys/dev/pci/drm/radeon/ni.c index d30b6406b..dd0b8c67b 100644 --- a/sys/dev/pci/drm/radeon/ni.c +++ b/sys/dev/pci/drm/radeon/ni.c @@ -1423,7 +1423,7 @@ void cayman_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) if (ring->rptr_save_reg) { uint32_t next_rptr = ring->wptr + 3 + 4 + 8; radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); - radeon_ring_write(ring, ((ring->rptr_save_reg - + radeon_ring_write(ring, ((ring->rptr_save_reg - PACKET3_SET_CONFIG_REG_START) >> 2)); radeon_ring_write(ring, next_rptr); } diff --git a/sys/dev/pci/drm/radeon/ni_dpm.c b/sys/dev/pci/drm/radeon/ni_dpm.c index 672d22392..3e1c1a392 100644 --- a/sys/dev/pci/drm/radeon/ni_dpm.c +++ b/sys/dev/pci/drm/radeon/ni_dpm.c @@ -2241,8 +2241,12 @@ static int ni_populate_mclk_value(struct radeon_device *rdev, ASIC_INTERNAL_MEMORY_SS, vco_freq)) { u32 reference_clock = rdev->clock.mpll.reference_freq; u32 decoded_ref = rv740_get_decoded_reference_divider(dividers.ref_div); - u32 clk_s = reference_clock * 5 / (decoded_ref * ss.rate); - u32 clk_v = ss.percentage * + u32 clk_s, clk_v; + + if (!decoded_ref) + return -EINVAL; + clk_s = reference_clock * 5 / (decoded_ref * ss.rate); + clk_v = ss.percentage * (0x4000 * dividers.whole_fb_div + 0x800 * dividers.frac_fb_div) / (clk_s * 625); mpll_ss1 &= ~CLKV_MASK; diff --git a/sys/dev/pci/drm/radeon/pptable.h b/sys/dev/pci/drm/radeon/pptable.h index 4c2eec49d..8118c6f15 100644 --- a/sys/dev/pci/drm/radeon/pptable.h +++ b/sys/dev/pci/drm/radeon/pptable.h @@ -114,8 +114,8 @@ typedef struct _ATOM_PPLIB_EXTENDEDHEADER USHORT usUVDTableOffset; //points to ATOM_PPLIB_UVD_Table USHORT usSAMUTableOffset; //points to ATOM_PPLIB_SAMU_Table USHORT usPPMTableOffset; //points to ATOM_PPLIB_PPM_Table - USHORT usACPTableOffset; //points to ATOM_PPLIB_ACP_Table - USHORT usPowerTuneTableOffset; //points to ATOM_PPLIB_POWERTUNE_Table + USHORT usACPTableOffset; //points to ATOM_PPLIB_ACP_Table + USHORT usPowerTuneTableOffset; //points to ATOM_PPLIB_POWERTUNE_Table } ATOM_PPLIB_EXTENDEDHEADER; //// ATOM_PPLIB_POWERPLAYTABLE::ulPlatformCaps @@ -196,14 +196,14 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE3 typedef struct _ATOM_PPLIB_POWERPLAYTABLE4 { ATOM_PPLIB_POWERPLAYTABLE3 basicTable3; - ULONG ulGoldenPPID; // PPGen use only + ULONG ulGoldenPPID; // PPGen use only ULONG ulGoldenRevision; // PPGen use only USHORT usVddcDependencyOnSCLKOffset; USHORT usVddciDependencyOnMCLKOffset; USHORT usVddcDependencyOnMCLKOffset; USHORT usMaxClockVoltageOnDCOffset; USHORT usVddcPhaseShedLimitsTableOffset; // Points to ATOM_PPLIB_PhaseSheddingLimits_Table - USHORT usMvddDependencyOnMCLKOffset; + USHORT usMvddDependencyOnMCLKOffset; } ATOM_PPLIB_POWERPLAYTABLE4, *LPATOM_PPLIB_POWERPLAYTABLE4; typedef struct _ATOM_PPLIB_POWERPLAYTABLE5 @@ -347,23 +347,23 @@ typedef struct _ATOM_PPLIB_RS780_CLOCK_INFO UCHAR ucPadding; // For proper alignment and size. USHORT usVDDC; // For the 780, use: None, Low, High, Variable UCHAR ucMaxHTLinkWidth; // From SBIOS - {2, 4, 8, 16} - UCHAR ucMinHTLinkWidth; // From SBIOS - {2, 4, 8, 16}. Effective only if CDLW enabled. Minimum down stream width could + UCHAR ucMinHTLinkWidth; // From SBIOS - {2, 4, 8, 16}. Effective only if CDLW enabled. Minimum down stream width could USHORT usHTLinkFreq; // See definition ATOM_PPLIB_RS780_HTLINKFREQ_xxx or in MHz(>=200). - ULONG ulFlags; + ULONG ulFlags; } ATOM_PPLIB_RS780_CLOCK_INFO; -#define ATOM_PPLIB_RS780_VOLTAGE_NONE 0 -#define ATOM_PPLIB_RS780_VOLTAGE_LOW 1 -#define ATOM_PPLIB_RS780_VOLTAGE_HIGH 2 -#define ATOM_PPLIB_RS780_VOLTAGE_VARIABLE 3 +#define ATOM_PPLIB_RS780_VOLTAGE_NONE 0 +#define ATOM_PPLIB_RS780_VOLTAGE_LOW 1 +#define ATOM_PPLIB_RS780_VOLTAGE_HIGH 2 +#define ATOM_PPLIB_RS780_VOLTAGE_VARIABLE 3 #define ATOM_PPLIB_RS780_SPMCLK_NONE 0 // We cannot change the side port memory clock, leave it as it is. #define ATOM_PPLIB_RS780_SPMCLK_LOW 1 #define ATOM_PPLIB_RS780_SPMCLK_HIGH 2 -#define ATOM_PPLIB_RS780_HTLINKFREQ_NONE 0 -#define ATOM_PPLIB_RS780_HTLINKFREQ_LOW 1 -#define ATOM_PPLIB_RS780_HTLINKFREQ_HIGH 2 +#define ATOM_PPLIB_RS780_HTLINKFREQ_NONE 0 +#define ATOM_PPLIB_RS780_HTLINKFREQ_LOW 1 +#define ATOM_PPLIB_RS780_HTLINKFREQ_HIGH 2 typedef struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO { @@ -405,14 +405,14 @@ typedef struct _ATOM_PPLIB_CI_CLOCK_INFO USHORT usMemoryClockLow; UCHAR ucMemoryClockHigh; - + UCHAR ucPCIEGen; USHORT usPCIELane; } ATOM_PPLIB_CI_CLOCK_INFO; typedef struct _ATOM_PPLIB_SUMO_CLOCK_INFO{ USHORT usEngineClockLow; //clockfrequency & 0xFFFF. The unit is in 10khz - UCHAR ucEngineClockHigh; //clockfrequency >> 16. + UCHAR ucEngineClockHigh; //clockfrequency >> 16. UCHAR vddcIndex; //2-bit vddc index; USHORT tdpLimit; //please initalize to 0 @@ -423,10 +423,10 @@ typedef struct _ATOM_PPLIB_SUMO_CLOCK_INFO{ typedef struct _ATOM_PPLIB_STATE_V2 { - //number of valid dpm levels in this state; Driver uses it to calculate the whole + //number of valid dpm levels in this state; Driver uses it to calculate the whole //size of the state: sizeof(ATOM_PPLIB_STATE_V2) + (ucNumDPMLevels - 1) * sizeof(UCHAR) UCHAR ucNumDPMLevels; - + //a index to the array of nonClockInfos UCHAR nonClockInfoIndex; /** @@ -436,9 +436,9 @@ typedef struct _ATOM_PPLIB_STATE_V2 } ATOM_PPLIB_STATE_V2; typedef struct _StateArray{ - //how many states we have + //how many states we have UCHAR ucNumEntries; - + ATOM_PPLIB_STATE_V2 states[1]; }StateArray; @@ -446,10 +446,10 @@ typedef struct _StateArray{ typedef struct _ClockInfoArray{ //how many clock levels we have UCHAR ucNumEntries; - + //sizeof(ATOM_PPLIB_CLOCK_INFO) UCHAR ucEntrySize; - + UCHAR clockInfo[1]; }ClockInfoArray; @@ -459,7 +459,7 @@ typedef struct _NonClockInfoArray{ UCHAR ucNumEntries; //sizeof(ATOM_PPLIB_NONCLOCK_INFO) UCHAR ucEntrySize; - + ATOM_PPLIB_NONCLOCK_INFO nonClockInfo[1]; }NonClockInfoArray; @@ -680,7 +680,7 @@ typedef struct _ATOM_PPLIB_PPM_Table ULONG ulPlatformTDC; ULONG ulSmallACPlatformTDC; ULONG ulApuTDP; - ULONG ulDGpuTDP; + ULONG ulDGpuTDP; ULONG ulDGpuUlvPower; ULONG ulTjmax; } ATOM_PPLIB_PPM_Table; diff --git a/sys/dev/pci/drm/radeon/radeon_bios.c b/sys/dev/pci/drm/radeon/radeon_bios.c index d850ac564..b7534b952 100644 --- a/sys/dev/pci/drm/radeon/radeon_bios.c +++ b/sys/dev/pci/drm/radeon/radeon_bios.c @@ -92,7 +92,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) bus_size_t size = 256 * 1024; /* ??? */ bus_space_handle_t bsh; bus_space_tag_t bst = rdev->memt; - + if (!(rdev->flags & RADEON_IS_IGP)) if (!radeon_card_posted(rdev)) return false; @@ -170,7 +170,7 @@ static bool radeon_read_bios(struct radeon_device *rdev) printf(": can't map PCI ROM (%d)\n", rc); return false; } - + rdev->bios = kmalloc(size, GFP_KERNEL); bus_space_read_region_1(rdev->memt, romh, 0, rdev->bios, size); bus_space_unmap(rdev->memt, romh, size); @@ -224,7 +224,7 @@ static bool radeon_read_platform_bios(struct radeon_device *rdev) bus_size_t size = 256 * 1024; /* ??? */ uint8_t *found = NULL; int i; - + if (!(rdev->flags & RADEON_IS_IGP)) if (!radeon_card_posted(rdev)) return false; @@ -244,7 +244,7 @@ static bool radeon_read_platform_bios(struct radeon_device *rdev) found = bios + i; break; } - + } if (found == NULL) { DRM_ERROR("bios size zero or checksum mismatch\n"); @@ -524,7 +524,7 @@ static bool r600_read_disabled_bios(struct radeon_device *rdev) uint32_t ctxsw_vid_lower_gpio_cntl; uint32_t lower_gpio_enable; bool r; - + /* * Some machines with RV610 running amd64 pass initial checks but later * fail atombios specific checks. Return early here so the bios will be diff --git a/sys/dev/pci/drm/radeon/radeon_drv.c b/sys/dev/pci/drm/radeon/radeon_drv.c index 8d3e97f1e..46cc5c6ac 100644 --- a/sys/dev/pci/drm/radeon/radeon_drv.c +++ b/sys/dev/pci/drm/radeon/radeon_drv.c @@ -726,7 +726,7 @@ const struct cfattach radeondrm_ca = { radeondrm_detach_kms, radeondrm_activate_kms }; -struct cfdriver radeondrm_cd = { +struct cfdriver radeondrm_cd = { NULL, "radeondrm", DV_DULL }; @@ -757,7 +757,7 @@ radeondrm_detach_kms(struct device *self, int flags) #endif radeon_acpi_fini(rdev); - + radeon_modeset_fini(rdev); radeon_device_fini(rdev); diff --git a/sys/dev/pci/drm/radeon/radeon_fence.c b/sys/dev/pci/drm/radeon/radeon_fence.c index 70ccf92c8..6d460e5ce 100644 --- a/sys/dev/pci/drm/radeon/radeon_fence.c +++ b/sys/dev/pci/drm/radeon/radeon_fence.c @@ -1085,7 +1085,6 @@ static signed long radeon_fence_default_wait(struct dma_fence *f, bool intr, break; } - KASSERT(sch_ident != NULL); t = schedule_timeout(t); if (t > 0 && intr && signal_pending(current)) diff --git a/sys/dev/pci/drm/radeon/radeon_legacy_crtc.c b/sys/dev/pci/drm/radeon/radeon_legacy_crtc.c index 6072ed5f2..648e78862 100644 --- a/sys/dev/pci/drm/radeon/radeon_legacy_crtc.c +++ b/sys/dev/pci/drm/radeon/radeon_legacy_crtc.c @@ -322,7 +322,7 @@ static void radeon_crtc_dpms(struct drm_crtc *crtc, int mode) */ if (rdev->flags & RADEON_SINGLE_CRTC) crtc_ext_cntl = RADEON_CRTC_CRT_ON; - + switch (mode) { case DRM_MODE_DPMS_ON: radeon_crtc->enabled = true; diff --git a/sys/dev/pci/drm/radeon/radeon_pm.c b/sys/dev/pci/drm/radeon/radeon_pm.c index db388419a..d7be77d1d 100644 --- a/sys/dev/pci/drm/radeon/radeon_pm.c +++ b/sys/dev/pci/drm/radeon/radeon_pm.c @@ -738,7 +738,7 @@ static ssize_t radeon_hwmon_show_sclk(struct device *dev, if (rdev->asic->dpm.get_current_sclk) sclk = radeon_dpm_get_current_sclk(rdev); - /* Value returned by dpm is in 10 KHz units, need to convert it into Hz + /* Value returned by dpm is in 10 KHz units, need to convert it into Hz for hwmon */ sclk *= 10000; diff --git a/sys/dev/pci/drm/radeon/radeon_sa.c b/sys/dev/pci/drm/radeon/radeon_sa.c index 0981948bd..c0f2aad4c 100644 --- a/sys/dev/pci/drm/radeon/radeon_sa.c +++ b/sys/dev/pci/drm/radeon/radeon_sa.c @@ -360,7 +360,7 @@ int radeon_sa_bo_new(struct radeon_device *rdev, /* if we have nothing to wait for block */ if (r == -ENOENT) { r = wait_event_interruptible_locked( - sa_manager->wq, + sa_manager->wq, radeon_sa_event(sa_manager, size, align) ); } diff --git a/sys/dev/pci/drm/radeon/rs690.c b/sys/dev/pci/drm/radeon/rs690.c index 8f31da188..616498d24 100644 --- a/sys/dev/pci/drm/radeon/rs690.c +++ b/sys/dev/pci/drm/radeon/rs690.c @@ -175,25 +175,25 @@ static void rs690_mc_init(struct radeon_device *rdev) rdev->mc.mc_vram_size = rdev->mc.real_vram_size; } - /* Use K8 direct mapping for fast fb access. */ + /* Use K8 direct mapping for fast fb access. */ rdev->fastfb_working = false; h_addr = G_00005F_K8_ADDR_EXT(RREG32_MC(R_00005F_MC_MISC_UMA_CNTL)); l_addr = RREG32_MC(R_00001E_K8_FB_LOCATION); k8_addr = ((unsigned long long)h_addr) << 32 | l_addr; #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) - if (k8_addr + rdev->mc.visible_vram_size < 0x100000000ULL) + if (k8_addr + rdev->mc.visible_vram_size < 0x100000000ULL) #endif { - /* FastFB shall be used with UMA memory. Here it is simply disabled when sideport + /* FastFB shall be used with UMA memory. Here it is simply disabled when sideport * memory is present. */ if (!rdev->mc.igp_sideport_enabled && radeon_fastfb == 1) { - DRM_INFO("Direct mapping: aper base at 0x%llx, replaced by direct mapping base 0x%llx.\n", + DRM_INFO("Direct mapping: aper base at 0x%llx, replaced by direct mapping base 0x%llx.\n", (unsigned long long)rdev->mc.aper_base, k8_addr); rdev->mc.aper_base = (resource_size_t)k8_addr; rdev->fastfb_working = true; } - } + } rs690_pm_info(rdev); radeon_vram_location(rdev, &rdev->mc, base); diff --git a/sys/dev/pci/drm/radeon/rv740_dpm.c b/sys/dev/pci/drm/radeon/rv740_dpm.c index d57a3e1df..4464fd21a 100644 --- a/sys/dev/pci/drm/radeon/rv740_dpm.c +++ b/sys/dev/pci/drm/radeon/rv740_dpm.c @@ -249,8 +249,12 @@ int rv740_populate_mclk_value(struct radeon_device *rdev, ASIC_INTERNAL_MEMORY_SS, vco_freq)) { u32 reference_clock = rdev->clock.mpll.reference_freq; u32 decoded_ref = rv740_get_decoded_reference_divider(dividers.ref_div); - u32 clk_s = reference_clock * 5 / (decoded_ref * ss.rate); - u32 clk_v = 0x40000 * ss.percentage * + u32 clk_s, clk_v; + + if (!decoded_ref) + return -EINVAL; + clk_s = reference_clock * 5 / (decoded_ref * ss.rate); + clk_v = 0x40000 * ss.percentage * (dividers.whole_fb_div + (dividers.frac_fb_div / 8)) / (clk_s * 10000); mpll_ss1 &= ~CLKV_MASK; diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c index 195b5d638..3610ed92a 100644 --- a/sys/dev/pci/if_ix.c +++ b/sys/dev/pci/if_ix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ix.c,v 1.198 2023/07/08 09:01:30 jmatthew Exp $ */ +/* $OpenBSD: if_ix.c,v 1.200 2023/07/18 16:01:20 bluhm Exp $ */ /****************************************************************************** @@ -37,6 +37,12 @@ #include #include +/* + * Our TCP/IP Stack could not handle packets greater than MAXMCLBYTES. + * This interface could not handle packets greater than IXGBE_TSO_SIZE. + */ +CTASSERT(MAXMCLBYTES <= IXGBE_TSO_SIZE); + /********************************************************************* * Driver version *********************************************************************/ @@ -1925,8 +1931,10 @@ ixgbe_setup_interface(struct ix_softc *sc) ifp->if_capabilities |= IFCAP_CSUM_IPv4; ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6; - if (sc->hw.mac.type != ixgbe_mac_82598EB) + if (sc->hw.mac.type != ixgbe_mac_82598EB) { + ifp->if_xflags |= IFXF_LRO; ifp->if_capabilities |= IFCAP_LRO; + } /* * Specify the media types supported by this sc and register @@ -2263,7 +2271,7 @@ ixgbe_allocate_transmit_buffers(struct tx_ring *txr) /* Create the descriptor buffer dma maps */ for (i = 0; i < sc->num_tx_desc; i++) { txbuf = &txr->tx_buffers[i]; - error = bus_dmamap_create(txr->txdma.dma_tag, IXGBE_TSO_SIZE, + error = bus_dmamap_create(txr->txdma.dma_tag, MAXMCLBYTES, sc->num_segs, PAGE_SIZE, 0, BUS_DMA_NOWAIT, &txbuf->map); diff --git a/sys/dev/pci/if_ixl.c b/sys/dev/pci/if_ixl.c index 3aa9c226c..5f42dd539 100644 --- a/sys/dev/pci/if_ixl.c +++ b/sys/dev/pci/if_ixl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ixl.c,v 1.87 2023/02/06 20:27:45 jan Exp $ */ +/* $OpenBSD: if_ixl.c,v 1.88 2023/07/19 20:22:05 jan Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -1274,6 +1274,7 @@ struct ixl_softc { unsigned int sc_atq_prod; unsigned int sc_atq_cons; + struct mutex sc_atq_mtx; struct ixl_dmamem sc_arq; struct task sc_arq_task; struct ixl_aq_bufs sc_arq_idle; @@ -1723,6 +1724,8 @@ ixl_attach(struct device *parent, struct device *self, void *aux) /* initialise the adminq */ + mtx_init(&sc->sc_atq_mtx, IPL_NET); + if (ixl_dmamem_alloc(sc, &sc->sc_atq, sizeof(struct ixl_aq_desc) * IXL_AQ_NUM, IXL_AQ_ALIGN) != 0) { printf("\n" "%s: unable to allocate atq\n", DEVNAME(sc)); @@ -3599,7 +3602,7 @@ ixl_atq_post(struct ixl_softc *sc, struct ixl_atq *iatq) struct ixl_aq_desc *atq, *slot; unsigned int prod; - /* assert locked */ + mtx_enter(&sc->sc_atq_mtx); atq = IXL_DMA_KVA(&sc->sc_atq); prod = sc->sc_atq_prod; @@ -3618,6 +3621,8 @@ ixl_atq_post(struct ixl_softc *sc, struct ixl_atq *iatq) prod &= IXL_AQ_MASK; sc->sc_atq_prod = prod; ixl_wr(sc, sc->sc_aq_regs->atq_tail, prod); + + mtx_leave(&sc->sc_atq_mtx); } static void @@ -3628,11 +3633,15 @@ ixl_atq_done(struct ixl_softc *sc) unsigned int cons; unsigned int prod; + mtx_enter(&sc->sc_atq_mtx); + prod = sc->sc_atq_prod; cons = sc->sc_atq_cons; - if (prod == cons) + if (prod == cons) { + mtx_leave(&sc->sc_atq_mtx); return; + } atq = IXL_DMA_KVA(&sc->sc_atq); @@ -3645,6 +3654,7 @@ ixl_atq_done(struct ixl_softc *sc) if (!ISSET(slot->iaq_flags, htole16(IXL_AQ_DD))) break; + KASSERT(slot->iaq_cookie != 0); iatq = (struct ixl_atq *)slot->iaq_cookie; iatq->iatq_desc = *slot; @@ -3661,6 +3671,8 @@ ixl_atq_done(struct ixl_softc *sc) BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); sc->sc_atq_cons = cons; + + mtx_leave(&sc->sc_atq_mtx); } static void @@ -3691,6 +3703,8 @@ ixl_atq_poll(struct ixl_softc *sc, struct ixl_aq_desc *iaq, unsigned int tm) unsigned int prod; unsigned int t = 0; + mtx_enter(&sc->sc_atq_mtx); + atq = IXL_DMA_KVA(&sc->sc_atq); prod = sc->sc_atq_prod; slot = atq + prod; @@ -3712,8 +3726,10 @@ ixl_atq_poll(struct ixl_softc *sc, struct ixl_aq_desc *iaq, unsigned int tm) while (ixl_rd(sc, sc->sc_aq_regs->atq_head) != prod) { delaymsec(1); - if (t++ > tm) + if (t++ > tm) { + mtx_leave(&sc->sc_atq_mtx); return (ETIMEDOUT); + } } bus_dmamap_sync(sc->sc_dmat, IXL_DMA_MAP(&sc->sc_atq), @@ -3724,6 +3740,7 @@ ixl_atq_poll(struct ixl_softc *sc, struct ixl_aq_desc *iaq, unsigned int tm) sc->sc_atq_cons = prod; + mtx_leave(&sc->sc_atq_mtx); return (0); } diff --git a/sys/dev/pci/if_myx.c b/sys/dev/pci/if_myx.c index 4b07f0b97..a4084487d 100644 --- a/sys/dev/pci/if_myx.c +++ b/sys/dev/pci/if_myx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_myx.c,v 1.117 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: if_myx.c,v 1.118 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2007 Reyk Floeter @@ -1377,7 +1377,6 @@ myx_down(struct myx_softc *sc) struct ifnet *ifp = &sc->sc_ac.ac_if; volatile struct myx_status *sts = sc->sc_sts; bus_dmamap_t map = sc->sc_sts_dma.mxm_map; - struct sleep_state sls; struct myx_cmd mc; int s; int ring; @@ -1397,9 +1396,9 @@ myx_down(struct myx_softc *sc) (void)myx_cmd(sc, MYXCMD_SET_IFDOWN, &mc, NULL); while (sc->sc_state != MYX_S_OFF) { - sleep_setup(&sls, sts, PWAIT, "myxdown"); + sleep_setup(sts, PWAIT, "myxdown"); membar_consumer(); - sleep_finish(&sls, PWAIT, 0, sc->sc_state != MYX_S_OFF); + sleep_finish(0, sc->sc_state != MYX_S_OFF); } s = splnet(); diff --git a/sys/dev/pci/if_rtwn.c b/sys/dev/pci/if_rtwn.c index 8961e8921..121b5a3cd 100644 --- a/sys/dev/pci/if_rtwn.c +++ b/sys/dev/pci/if_rtwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rtwn.c,v 1.40 2022/04/21 21:03:03 stsp Exp $ */ +/* $OpenBSD: if_rtwn.c,v 1.41 2023/07/14 14:28:47 kevlo Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini @@ -1022,7 +1022,7 @@ rtwn_tx(void *cookie, struct mbuf *m, struct ieee80211_node *ni) /* Fill Tx descriptor. */ txd = &tx_ring->desc[tx_ring->cur]; - if (htole32(txd->txdw0) & R92C_RXDW0_OWN) { + if (htole32(txd->txdw0) & R92C_TXDW0_OWN) { m_freem(m); return (ENOBUFS); } diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index db59abf99..cd787b4fd 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1248,11 +1248,11 @@ ehci_dump_sqtds(struct ehci_soft_qtd *sqtd) void ehci_dump_sqtd(struct ehci_soft_qtd *sqtd) { - usb_syncmem(&sqtd->dma, sqtd->offs, + usb_syncmem(&sqtd->dma, sqtd->offs, sizeof(sqtd->qtd), BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); printf("QTD(%p) at 0x%08x:\n", sqtd, sqtd->physaddr); ehci_dump_qtd(&sqtd->qtd); - usb_syncmem(&sqtd->dma, sqtd->offs, + usb_syncmem(&sqtd->dma, sqtd->offs, sizeof(sqtd->qtd), BUS_DMASYNC_PREREAD); } diff --git a/sys/dev/usb/ehcireg.h b/sys/dev/usb/ehcireg.h index 10c50a5cd..ff90ed2e8 100644 --- a/sys/dev/usb/ehcireg.h +++ b/sys/dev/usb/ehcireg.h @@ -167,7 +167,7 @@ #define EHCI_USBMODE_CM_M 0x00000003 #define EHCI_USBMODE_CM_IDLE 0x00000000 #define EHCI_USBMODE_CM_DEVICE 0x00000002 -#define EHCI_USBMODE_CM_HOST 0x00000003 +#define EHCI_USBMODE_CM_HOST 0x00000003 #define EHCI_FLALIGN_ALIGN 0x1000 diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb index 88fff1b7c..c5002f503 100644 --- a/sys/dev/usb/files.usb +++ b/sys/dev/usb/files.usb @@ -236,7 +236,7 @@ attach axen at uhub file dev/usb/if_axen.c axen # SMSC LAN95xx -device smsc: ether, ifnet, mii, ifmedia +device smsc: ether, ifnet, mii, ifmedia attach smsc at uhub file dev/usb/if_smsc.c smsc diff --git a/sys/dev/usb/if_athn_usb.c b/sys/dev/usb/if_athn_usb.c index 49d5c06cf..d6b470f62 100644 --- a/sys/dev/usb/if_athn_usb.c +++ b/sys/dev/usb/if_athn_usb.c @@ -618,7 +618,7 @@ athn_usb_do_async(struct athn_usb_softc *usc, printf("%s: host cmd queue overrun\n", usc->usb_dev.dv_xname); return; /* XXX */ } - + s = splusb(); cmd = &ring->cmd[ring->cur]; cmd->cb = cb; @@ -897,7 +897,7 @@ athn_usb_wmi_xcmd(struct athn_usb_softc *usc, uint16_t cmd_id, void *ibuf, } usc->obuf = obuf; usc->wait_cmd_id = cmd_id; - /* + /* * Wait for WMI command complete interrupt. In case it does not fire * wait until the USB transfer times out to avoid racing the transfer. */ @@ -911,7 +911,7 @@ athn_usb_wmi_xcmd(struct athn_usb_softc *usc, uint16_t cmd_id, void *ibuf, } } - /* + /* * Both the WMI command and transfer are done or have timed out. * Allow other threads to enter this function and use data->xfer. */ @@ -1260,7 +1260,7 @@ athn_usb_newauth(struct ieee80211com *ic, struct ieee80211_node *ni, return ENOSPC; } - /* + /* * In a process context, try to add this node to the * firmware table and confirm the AUTH request. */ @@ -1280,7 +1280,7 @@ athn_usb_node_free(struct ieee80211com *ic, struct ieee80211_node *ni) struct athn_usb_softc *usc = ic->ic_softc; struct athn_node *an = (struct athn_node *)ni; - /* + /* * Remove the node from the firmware table in a process context. * Pass an index rather than the pointer which we will free. */ @@ -1378,7 +1378,7 @@ athn_usb_clean_nodes(void *arg, struct ieee80211_node *ni) struct ieee80211com *ic = &usc->sc_sc.sc_ic; struct athn_node *an = (struct athn_node *)ni; - /* + /* * Don't remove the default node (used for management frames). * Nodes which are not in the firmware table also have index zero. */ @@ -1392,7 +1392,7 @@ athn_usb_clean_nodes(void *arg, struct ieee80211_node *ni) return; } - /* + /* * Kick off inactive associated nodes. This won't help * immediately but will help if the new STA retries later. */ diff --git a/sys/dev/usb/if_athn_usb.h b/sys/dev/usb/if_athn_usb.h index 75bc0e8d3..ee257ba95 100644 --- a/sys/dev/usb/if_athn_usb.h +++ b/sys/dev/usb/if_athn_usb.h @@ -135,7 +135,7 @@ struct ar_htc_target_rate { #define AR_RC_SGI_FLAG 0x00000004 #define AR_RC_HT_FLAG 0x00000008 #define AR_RC_STBC_FLAG 0x00000030 /* 2 bits */ -#define AR_RC_WEP_TKIP_FLAG 0x00000100 +#define AR_RC_WEP_TKIP_FLAG 0x00000100 struct ar_htc_rateset lg_rates; struct ar_htc_rateset ht_rates; @@ -181,7 +181,7 @@ struct ar_htc_cap_target { struct ar_wmi_evt_txstatus { uint8_t cookie; - /* + /* * Legacy rates are indicated as rate array indices. * HT rates are indicated as MCS indices. */ @@ -475,7 +475,7 @@ struct athn_usb_softc { uint8_t ep_mgmt; uint8_t ep_data[EDCA_NUM_AC]; - /* + /* * Firmware cannot handle more than 8 STAs. * We use a bitmask to keep track of available slots in the firmware's * node array. A 1 bit at index N, as determined by ffs(3), means the diff --git a/sys/dev/usb/if_atureg.h b/sys/dev/usb/if_atureg.h index f298f9040..5c77e5eea 100644 --- a/sys/dev/usb/if_atureg.h +++ b/sys/dev/usb/if_atureg.h @@ -161,7 +161,7 @@ struct atu_cdata { struct atu_list_head atu_tx_free; u_int8_t atu_tx_inuse; - u_int8_t atu_tx_last_idx; + u_int8_t atu_tx_last_idx; }; #define MAX_SSID_LEN 32 @@ -190,11 +190,11 @@ struct atu_softc { struct atu_cdata atu_cdata; struct timeval atu_rx_notice; - + u_int8_t atu_bssid[ETHER_ADDR_LEN]; enum atu_radio_type atu_radio; u_int16_t atu_quirk; - + u_int8_t atu_channel; u_int16_t atu_desired_channel; u_int8_t atu_mode; @@ -297,7 +297,7 @@ struct atu_cmd_card_config { uByte Cmd; uByte Reserved; uWord Size; - + uByte ExcludeUnencrypted; uByte PromiscuousMode; uByte ShortRetryLimit; @@ -321,7 +321,7 @@ struct atu_cmd_do_scan { uByte Cmd; uByte Reserved; uWord Size; - + uByte BSSID[ETHER_ADDR_LEN]; uByte SSID[MAX_SSID_LEN]; uByte ScanType; @@ -330,7 +330,7 @@ struct atu_cmd_do_scan { uWord MinChannelTime; uWord MaxChannelTime; uByte SSID_Len; - uByte InternationalScan; + uByte InternationalScan; } __packed; #define ATU_SCAN_ACTIVE 0x00 @@ -341,7 +341,7 @@ struct atu_cmd_join { uByte Cmd; uByte Reserved; uWord Size; - + uByte bssid[ETHER_ADDR_LEN]; uByte essid[32]; uByte bss_type; @@ -356,13 +356,13 @@ struct atu_cmd_start_ibss { uByte Cmd; uByte Reserved; uWord Size; - + uByte BSSID[ETHER_ADDR_LEN]; uByte SSID[32]; - uByte BSSType; - uByte Channel; + uByte BSSType; + uByte Channel; uByte SSIDSize; - uByte Res[3]; + uByte Res[3]; } __packed; /* @@ -406,7 +406,7 @@ struct atu_fw { u_int8_t patch; u_int8_t build; } __packed; - + /* * The header the AT76c503 puts in front of RX packets (for both management & * data) diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c index c58406b7d..6887c4849 100644 --- a/sys/dev/usb/if_axe.c +++ b/sys/dev/usb/if_axe.c @@ -545,7 +545,7 @@ axe_ax88178_init(struct axe_softc *sc) AXE_GPIO_WRITE(AXE_GPIO1_EN, 30); AXE_GPIO_WRITE(AXE_GPIO1_EN | AXE_GPIO1, 30); } else { - val = gpio0 == 1 ? AXE_GPIO0 | AXE_GPIO0_EN : + val = gpio0 == 1 ? AXE_GPIO0 | AXE_GPIO0_EN : AXE_GPIO1 | AXE_GPIO1_EN; AXE_GPIO_WRITE(val | AXE_GPIO2 | AXE_GPIO2_EN, 30); AXE_GPIO_WRITE(val | AXE_GPIO2_EN, 300); diff --git a/sys/dev/usb/if_axen.c b/sys/dev/usb/if_axen.c index 7b4cc2d40..651920693 100644 --- a/sys/dev/usb/if_axen.c +++ b/sys/dev/usb/if_axen.c @@ -382,7 +382,7 @@ axen_iff(struct axen_softc *sc) } } - axen_cmd(sc, AXEN_CMD_MAC_WRITE_FILTER, 8, AXEN_FILTER_MULTI, + axen_cmd(sc, AXEN_CMD_MAC_WRITE_FILTER, 8, AXEN_FILTER_MULTI, (void *)&hashtbl); USETW(wval, rxmode); axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); @@ -394,7 +394,7 @@ axen_reset(struct axen_softc *sc) { if (usbd_is_dying(sc->axen_udev)) return; - + axen_ax88179_init(sc); /* Wait a little while for the chip to get its brains in order. */ @@ -625,19 +625,19 @@ axen_attach(struct device *parent, struct device *self, void *aux) /* decide on what our bufsize will be */ switch (sc->axen_udev->speed) { case USB_SPEED_FULL: - sc->axen_bufsz = AXEN_BUFSZ_LS * 1024; + sc->axen_bufsz = AXEN_BUFSZ_LS * 1024; break; case USB_SPEED_HIGH: - sc->axen_bufsz = AXEN_BUFSZ_HS * 1024; + sc->axen_bufsz = AXEN_BUFSZ_HS * 1024; break; case USB_SPEED_SUPER: - sc->axen_bufsz = AXEN_BUFSZ_SS * 1024; + sc->axen_bufsz = AXEN_BUFSZ_SS * 1024; break; default: printf("%s: not supported usb bus type", sc->axen_dev.dv_xname); return; } - + /* Find endpoints. */ for (i = 0; i < id->bNumEndpoints; i++) { ed = usbd_interface2endpoint_descriptor(sc->axen_iface, i); @@ -914,7 +914,7 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) goto done; } - /* + /* * buffer map * [packet #0]...[packet #n][pkt hdr#0]..[pkt hdr#n][recv_hdr] * each packet has 0xeeee as pseudo header.. @@ -945,9 +945,9 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) */ #if 1 /* XXX: paranoiac check. need to remove later */ -#define AXEN_MAX_PACKED_PACKET 200 +#define AXEN_MAX_PACKED_PACKET 200 if (pkt_count > AXEN_MAX_PACKED_PACKET) { - DPRINTF(("Too many packets (%d) in a transaction, discard.\n", + DPRINTF(("Too many packets (%d) in a transaction, discard.\n", pkt_count)); goto done; } @@ -988,7 +988,7 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) #ifdef AXEN_TOE /* checksum err */ - if ((pkt_hdr & AXEN_RXHDR_L3CSUM_ERR) || + if ((pkt_hdr & AXEN_RXHDR_L3CSUM_ERR) || (pkt_hdr & AXEN_RXHDR_L4CSUM_ERR)) { printf("%s: checksum err (pkt#%d)\n", sc->axen_dev.dv_xname, pkt_count); @@ -998,11 +998,11 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) } int l4_type; - l4_type = (pkt_hdr & AXEN_RXHDR_L4_TYPE_MASK) >> + l4_type = (pkt_hdr & AXEN_RXHDR_L4_TYPE_MASK) >> AXEN_RXHDR_L4_TYPE_OFFSET; if ((l4_type == AXEN_RXHDR_L4_TYPE_TCP) || - (l4_type == AXEN_RXHDR_L4_TYPE_UDP)) + (l4_type == AXEN_RXHDR_L4_TYPE_UDP)) m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; #endif @@ -1013,7 +1013,7 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) nextpkt: /* - * prepare next packet + * prepare next packet * as each packet will be aligned 8byte boundary, * need to fix up the start point of the buffer. */ diff --git a/sys/dev/usb/if_axenreg.h b/sys/dev/usb/if_axenreg.h index 8de2c6d50..33d075b85 100644 --- a/sys/dev/usb/if_axenreg.h +++ b/sys/dev/usb/if_axenreg.h @@ -20,7 +20,7 @@ #define AXEN_REV_UA2 1 /* receive header */ -/* +/* * +-multicast/broadcast * | +-rx_ok * | | ++-----L3_type (1:ipv4, 0/2:ipv6) @@ -84,7 +84,7 @@ #define AXEN_CMD_CMD(x) ((x) & 0x00FF) /* ---MAC--- */ -/* 1byte cmd */ +/* 1byte cmd */ #define AXEN_CMD_MAC_READ 0x1001 #define AXEN_CMD_MAC_WRITE 0x1101 @@ -141,7 +141,7 @@ #define AXEN_PAUSE_LOW_WATERMARK 0x55 -/* 2byte cmd */ +/* 2byte cmd */ #define AXEN_CMD_MAC_READ2 0x2001 #define AXEN_CMD_MAC_WRITE2 0x2101 @@ -149,7 +149,7 @@ #define AXEN_RXCTL_STOP 0x0000 #define AXEN_RXCTL_PROMISC 0x0001 #define AXEN_RXCTL_ACPT_ALL_MCAST 0x0002 -#define AXEN_RXCTL_HA8B 0x0004 +#define AXEN_RXCTL_HA8B 0x0004 #define AXEN_RXCTL_AUTOB 0x0008 #define AXEN_RXCTL_ACPT_BCAST 0x0010 #define AXEN_RXCTL_ACPT_PHY_MCAST 0x0020 @@ -176,22 +176,22 @@ #define AXEN_CMD_EEPROM_READ 0x2004 #define AXEN_EEPROM_STAT 0x43 -/* 5byte cmd */ +/* 5byte cmd */ #define AXEN_CMD_MAC_SET_RXSR 0x5101 #define AXEN_RX_BULKIN_QCTRL 0x2e -/* 6byte cmd */ +/* 6byte cmd */ #define AXEN_CMD_MAC_READ_ETHER 0x6001 #define AXEN_CMD_MAC_WRITE_ETHER 0x6101 #define AXEN_CMD_MAC_NODE_ID 0x10 -/* 8byte cmd */ +/* 8byte cmd */ #define AXEN_CMD_MAC_READ_FILTER 0x8001 #define AXEN_CMD_MAC_WRITE_FILTER 0x8101 #define AXEN_FILTER_MULTI 0x16 /* ---PHY--- */ -/* 2byte cmd */ +/* 2byte cmd */ #define AXEN_CMD_MII_READ_REG 0x2002 #define AXEN_CMD_MII_WRITE_REG 0x2102 diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c index 6ca142c1e..fbe2950ae 100644 --- a/sys/dev/usb/if_cdce.c +++ b/sys/dev/usb/if_cdce.c @@ -225,7 +225,7 @@ cdce_attach(struct device *parent, struct device *self, void *aux) } switch(desc->bDescriptorSubtype) { case UDESCSUB_CDC_UNION: - ud = (struct usb_cdc_union_descriptor *)desc; + ud = (struct usb_cdc_union_descriptor *)desc; if ((sc->cdce_flags & CDCE_SWAPUNION) == 0 && ud->bMasterInterface == ctl_ifcno) data_ifcno = ud->bSlaveInterface[0]; @@ -290,10 +290,10 @@ cdce_attach(struct device *parent, struct device *self, void *aux) for (j = 0; j < numalts; j++) { if (usbd_set_interface(sc->cdce_data_iface, j)) { - printf("%s: interface alternate setting %d failed\n", + printf("%s: interface alternate setting %d failed\n", sc->cdce_dev.dv_xname, j); return; - } + } /* Find endpoints. */ id = usbd_get_interface_descriptor(sc->cdce_data_iface); sc->cdce_bulkin_no = sc->cdce_bulkout_no = -1; @@ -330,7 +330,7 @@ cdce_attach(struct device *parent, struct device *self, void *aux) goto found; } } - + if (sc->cdce_bulkin_no == -1) { printf("%s: could not find data bulk in\n", sc->cdce_dev.dv_xname); @@ -385,7 +385,7 @@ found: int cdce_detach(struct device *self, int flags) { - struct cdce_softc *sc = (struct cdce_softc *)self; + struct cdce_softc *sc = (struct cdce_softc *)self; struct ifnet *ifp = GET_IFP(sc); int s; diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index 518a56924..324bc0162 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.128 2023/01/01 21:45:40 kettenis Exp $ */ +/* $OpenBSD: xhci.c,v 1.130 2023/07/20 09:43:00 claudio Exp $ */ /* * Copyright (c) 2014-2015 Martin Pieuchot diff --git a/sys/isofs/cd9660/cd9660_extern.h b/sys/isofs/cd9660/cd9660_extern.h index 2a5348e17..b47f3373b 100644 --- a/sys/isofs/cd9660/cd9660_extern.h +++ b/sys/isofs/cd9660/cd9660_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_extern.h,v 1.15 2020/01/20 23:21:55 claudio Exp $ */ +/* $OpenBSD: cd9660_extern.h,v 1.16 2023/07/17 09:41:20 semarie Exp $ */ /* $NetBSD: cd9660_extern.h,v 1.1 1997/01/24 00:24:53 cgd Exp $ */ /*- @@ -58,15 +58,15 @@ struct iso_mnt { int logical_block_size; int im_bshift; int im_bmask; - + int volume_space_size; struct netexport im_export; - + char root[ISODCL (157, 190)]; int root_extent; int root_size; enum ISO_FTYPE iso_ftype; - + int rr_skip; int rr_skip0; @@ -94,10 +94,8 @@ int cd9660_vptofh(struct vnode *, struct fid *); int cd9660_init(struct vfsconf *); int cd9660_check_export(struct mount *, struct mbuf *, int *, struct ucred **); -#define cd9660_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \ - size_t, struct proc *))eopnotsupp) -int cd9660_mountroot(void); +int cd9660_mountroot(void); extern const struct vops cd9660_vops; extern const struct vops cd9660_specvops; diff --git a/sys/isofs/cd9660/cd9660_lookup.c b/sys/isofs/cd9660/cd9660_lookup.c index b64a0f84a..121726e98 100644 --- a/sys/isofs/cd9660/cd9660_lookup.c +++ b/sys/isofs/cd9660/cd9660_lookup.c @@ -131,7 +131,7 @@ cd9660_lookup(void *v) dp = VTOI(vdp); imp = dp->i_mnt; lockparent = flags & LOCKPARENT; - + /* * Check accessibility of directory. */ @@ -141,7 +141,7 @@ cd9660_lookup(void *v) if ((flags & ISLASTCN) && (vdp->v_mount->mnt_flag & MNT_RDONLY) && (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) return (EROFS); - + /* * We now have a segment name to search for, and a directory to search. * @@ -162,7 +162,7 @@ cd9660_lookup(void *v) len--; name++; } - + /* * If there is cached information on a previous search of * this directory, pick up where we last left off. @@ -183,14 +183,14 @@ cd9660_lookup(void *v) } else { dp->i_offset = dp->i_diroff; if ((entryoffsetinblock = dp->i_offset & bmask) && - (error = cd9660_bufatoff(dp, (off_t)dp->i_offset, NULL, + (error = cd9660_bufatoff(dp, (off_t)dp->i_offset, NULL, &bp))) return (error); numdirpasses = 2; iso_nchstats.ncs_2passes++; } endsearch = dp->i_size; - + searchloop: while (dp->i_offset < endsearch) { /* @@ -212,7 +212,7 @@ searchloop: */ ep = (struct iso_directory_record *) ((char *)bp->b_data + entryoffsetinblock); - + reclen = isonum_711(ep->length); if (reclen == 0) { /* skip to next block, if any */ @@ -220,21 +220,21 @@ searchloop: (dp->i_offset & ~bmask) + imp->logical_block_size; continue; } - + if (reclen < ISO_DIRECTORY_RECORD_SIZE) /* illegal entry, stop */ break; - + if (entryoffsetinblock + reclen > imp->logical_block_size) /* entries are not allowed to cross boundaries */ break; - + namelen = isonum_711(ep->name_len); - + if (reclen < ISO_DIRECTORY_RECORD_SIZE + namelen) /* illegal entry, stop */ break; - + /* * Check for a name match. */ @@ -256,7 +256,7 @@ searchloop: if (namelen != 1 || ep->name[0] != 0) goto notfound; - } else if (!(res = isofncmp(name, len, + } else if (!(res = isofncmp(name, len, ep->name, namelen, imp->joliet_level))) { if (isonum_711(ep->flags)&2) ino = isodirino(ep, imp); @@ -335,11 +335,11 @@ notfound: if (nameiop == CREATE || nameiop == RENAME) return (EJUSTRETURN); return (ENOENT); - + found: if (numdirpasses == 2) iso_nchstats.ncs_pass2++; - + /* * Found component in pathname. * If the final component of path name, save information @@ -347,7 +347,7 @@ found: */ if ((flags & ISLASTCN) && nameiop == LOOKUP) dp->i_diroff = dp->i_offset; - + /* * Step through the translation in the name. We do not `iput' the * directory because we may need it again if a symbolic link @@ -407,7 +407,7 @@ found: } *vpp = tdp; } - + /* * Insert name into cache if appropriate. */ @@ -422,7 +422,7 @@ found: * remaining space in the directory. */ int -cd9660_bufatoff(struct iso_node *ip, off_t offset, char **res, +cd9660_bufatoff(struct iso_node *ip, off_t offset, char **res, struct buf **bpp) { struct iso_mnt *imp; @@ -434,7 +434,7 @@ cd9660_bufatoff(struct iso_node *ip, off_t offset, char **res, imp = ip->i_mnt; lbn = lblkno(imp, offset); bsize = blksize(imp, ip, lbn); - + if ((error = bread(vp, lbn, bsize, &bp)) != 0) { brelse(bp); *bpp = NULL; diff --git a/sys/isofs/cd9660/cd9660_node.c b/sys/isofs/cd9660/cd9660_node.c index bce99d77c..d34705b27 100644 --- a/sys/isofs/cd9660/cd9660_node.c +++ b/sys/isofs/cd9660/cd9660_node.c @@ -132,7 +132,7 @@ cd9660_ihashins(struct iso_node *ip) iq->i_number == ip->i_number) return (EEXIST); } - + if ((iq = *ipp) != NULL) iq->i_prev = &ip->i_next; ip->i_next = iq; @@ -155,7 +155,7 @@ cd9660_ihashrem(struct iso_node *ip) if (ip->i_prev == NULL) return; - + /* XXX locking lock hash list? */ if ((iq = ip->i_next) != NULL) iq->i_prev = ip->i_prev; @@ -183,7 +183,7 @@ cd9660_inactive(void *v) if (prtactive && vp->v_usecount != 0) vprint("cd9660_inactive: pushing active", vp); #endif - + ip->i_flag = 0; VOP_UNLOCK(vp); /* @@ -239,7 +239,7 @@ cd9660_defattr(struct iso_directory_record *isodir, struct iso_node *inop, struct iso_mnt *imp; struct iso_extended_attributes *ap = NULL; int off; - + if (isonum_711(isodir->flags)&2) { inop->inode.iso_mode = S_IFDIR; /* @@ -260,7 +260,7 @@ cd9660_defattr(struct iso_directory_record *isodir, struct iso_node *inop, } if (bp) { ap = (struct iso_extended_attributes *)bp->b_data; - + if (isonum_711(ap->version) == 1) { if (!(ap->perm[1]&0x10)) inop->inode.iso_mode |= S_IRUSR; @@ -300,7 +300,7 @@ cd9660_deftstamp(struct iso_directory_record *isodir, struct iso_node *inop, struct iso_mnt *imp; struct iso_extended_attributes *ap = NULL; int off; - + if (!bp && ((imp = inop->i_mnt)->im_flags & ISOFSMNT_EXTATT) && (off = isonum_711(isodir->ext_attr_length))) { @@ -310,7 +310,7 @@ cd9660_deftstamp(struct iso_directory_record *isodir, struct iso_node *inop, } if (bp) { ap = (struct iso_extended_attributes *)bp->b_data; - + if (isonum_711(ap->version) == 1) { if (!cd9660_tstamp_conv17(ap->ftime,&inop->inode.iso_atime)) cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_atime); @@ -336,7 +336,7 @@ cd9660_tstamp_conv7(u_char *pi, struct timespec *pu) int crtime, days; int y, m, d, hour, minute, second; signed char tz; - + y = pi[0] + 1900; m = pi[1]; d = pi[2]; @@ -344,7 +344,7 @@ cd9660_tstamp_conv7(u_char *pi, struct timespec *pu) minute = pi[4]; second = pi[5]; tz = (signed char) pi[6]; - + if (y < 1970) { pu->tv_sec = 0; pu->tv_nsec = 0; @@ -362,7 +362,7 @@ cd9660_tstamp_conv7(u_char *pi, struct timespec *pu) days = 367*(y-1960)-7*(y+(m+9)/12)/4-3*((y+(m+9)/12-1)/100+1)/4+275*m/9+d-239; #endif crtime = ((((days * 24) + hour) * 60 + minute) * 60) + second; - + /* timezone offset is unreliable on some disks */ if (-48 <= tz && tz <= 52) crtime -= tz * 15 * 60; @@ -376,7 +376,7 @@ static u_int cd9660_chars2ui(u_char *begin, int len) { u_int rc; - + for (rc = 0; --len >= 0;) { rc *= 10; rc += *begin++ - '0'; @@ -388,28 +388,28 @@ int cd9660_tstamp_conv17(u_char *pi, struct timespec *pu) { u_char buf[7]; - + /* year:"0001"-"9999" -> -1900 */ buf[0] = cd9660_chars2ui(pi,4) - 1900; - + /* month: " 1"-"12" -> 1 - 12 */ buf[1] = cd9660_chars2ui(pi + 4,2); - + /* day: " 1"-"31" -> 1 - 31 */ buf[2] = cd9660_chars2ui(pi + 6,2); - + /* hour: " 0"-"23" -> 0 - 23 */ buf[3] = cd9660_chars2ui(pi + 8,2); - + /* minute:" 0"-"59" -> 0 - 59 */ buf[4] = cd9660_chars2ui(pi + 10,2); - + /* second:" 0"-"59" -> 0 - 59 */ buf[5] = cd9660_chars2ui(pi + 12,2); - + /* difference of GMT */ buf[6] = pi[16]; - + return (cd9660_tstamp_conv7(buf,pu)); } diff --git a/sys/isofs/cd9660/cd9660_node.h b/sys/isofs/cd9660/cd9660_node.h index 3da440044..8b25a052d 100644 --- a/sys/isofs/cd9660/cd9660_node.h +++ b/sys/isofs/cd9660/cd9660_node.h @@ -76,7 +76,7 @@ struct iso_node { doff_t iso_start; ISO_RRIP_INODE inode; - struct cluster_info i_ci; + struct cluster_info i_ci; }; #define i_forw i_chain[0] diff --git a/sys/isofs/cd9660/cd9660_rrip.c b/sys/isofs/cd9660/cd9660_rrip.c index 3143b87f6..01fa89576 100644 --- a/sys/isofs/cd9660/cd9660_rrip.c +++ b/sys/isofs/cd9660/cd9660_rrip.c @@ -114,21 +114,21 @@ cd9660_rrip_slink(void *v, ISO_RRIP_ANALYZE *ana) ISO_RRIP_SLINK_COMPONENT *pcompe; int len, wlen, cont; char *outbuf, *inbuf; - + pcomp = (ISO_RRIP_SLINK_COMPONENT *)p->component; pcompe = (ISO_RRIP_SLINK_COMPONENT *)((char *)p + isonum_711(p->h.length)); len = *ana->outlen; outbuf = ana->outbuf; cont = ana->cont; - + /* * Gathering a Symbolic name from each component with path */ for (; pcomp < pcompe; pcomp = (ISO_RRIP_SLINK_COMPONENT *) ((char *)pcomp + ISO_RRIP_SLSIZ + isonum_711(pcomp->clen))) { - + if (!cont) { if (len < ana->maxlen) { len++; @@ -136,29 +136,29 @@ cd9660_rrip_slink(void *v, ISO_RRIP_ANALYZE *ana) } } cont = 0; - + inbuf = ".."; wlen = 0; - + switch (*pcomp->cflag) { - + case ISO_SUSP_CFLAG_CURRENT: /* Inserting Current */ wlen = 1; break; - + case ISO_SUSP_CFLAG_PARENT: /* Inserting Parent */ wlen = 2; break; - + case ISO_SUSP_CFLAG_ROOT: /* Inserting slash for ROOT */ /* start over from beginning(?) */ outbuf -= len; len = 0; break; - + case ISO_SUSP_CFLAG_VOLROOT: /* Inserting a mount point i.e. "/cdrom" */ /* same as above */ @@ -167,13 +167,13 @@ cd9660_rrip_slink(void *v, ISO_RRIP_ANALYZE *ana) inbuf = ana->imp->im_mountp->mnt_stat.f_mntonname; wlen = strlen(inbuf); break; - + case ISO_SUSP_CFLAG_HOST: /* Inserting hostname i.e. "kurt.tools.de" */ inbuf = hostname; wlen = hostnamelen; break; - + case ISO_SUSP_CFLAG_CONTINUE: cont = 1; /* FALLTHROUGH */ @@ -187,7 +187,7 @@ cd9660_rrip_slink(void *v, ISO_RRIP_ANALYZE *ana) wlen = ana->maxlen + 1; break; } - + if (len + wlen > ana->maxlen) { /* indicate error to caller */ ana->cont = 1; @@ -196,7 +196,7 @@ cd9660_rrip_slink(void *v, ISO_RRIP_ANALYZE *ana) *ana->outlen = 0; return (0); } - + bcopy(inbuf, outbuf, wlen); outbuf += wlen; len += wlen; @@ -204,7 +204,7 @@ cd9660_rrip_slink(void *v, ISO_RRIP_ANALYZE *ana) ana->outbuf = outbuf; *ana->outlen = len; ana->cont = cont; - + if (!isonum_711(p->flags)) { ana->fields &= ~ISO_SUSP_SLINK; return (ISO_SUSP_SLINK); @@ -222,28 +222,28 @@ cd9660_rrip_altname(void *v, ISO_RRIP_ANALYZE *ana) char *inbuf; int wlen; int cont; - + inbuf = ".."; wlen = 0; cont = 0; - + switch (*p->flags) { case ISO_SUSP_CFLAG_CURRENT: /* Inserting Current */ wlen = 1; break; - + case ISO_SUSP_CFLAG_PARENT: /* Inserting Parent */ wlen = 2; break; - + case ISO_SUSP_CFLAG_HOST: /* Inserting hostname i.e. "kurt.tools.de" */ inbuf = hostname; wlen = hostnamelen; break; - + case ISO_SUSP_CFLAG_CONTINUE: cont = 1; /* FALLTHROUGH */ @@ -252,13 +252,13 @@ cd9660_rrip_altname(void *v, ISO_RRIP_ANALYZE *ana) wlen = isonum_711(p->h.length) - 5; inbuf = (char *)p + 5; break; - + default: printf("RRIP with incorrect NM flags?\n"); wlen = ana->maxlen + 1; break; } - + if ((*ana->outlen += wlen) > ana->maxlen) { /* treat as no name field */ ana->fields &= ~ISO_SUSP_ALTNAME; @@ -266,10 +266,10 @@ cd9660_rrip_altname(void *v, ISO_RRIP_ANALYZE *ana) *ana->outlen = 0; return (0); } - + bcopy(inbuf, ana->outbuf, wlen); ana->outbuf += wlen; - + if (!cont) { ana->fields &= ~ISO_SUSP_ALTNAME; return (ISO_SUSP_ALTNAME); @@ -329,14 +329,14 @@ cd9660_rrip_tstamp(void *v, ISO_RRIP_ANALYZE *ana) { ISO_RRIP_TSTAMP *p = v; u_char *ptime; - + ptime = p->time; - + /* Check a format of time stamp (7bytes/17bytes) */ if (!(*p->flags & ISO_SUSP_TSTAMP_FORM17)) { if (*p->flags & ISO_SUSP_TSTAMP_CREAT) ptime += 7; - + if (*p->flags & ISO_SUSP_TSTAMP_MODIFY) { cd9660_tstamp_conv7(ptime, &ana->inop->inode.iso_mtime); @@ -344,7 +344,7 @@ cd9660_rrip_tstamp(void *v, ISO_RRIP_ANALYZE *ana) } else bzero(&ana->inop->inode.iso_mtime, sizeof(struct timespec)); - + if (*p->flags & ISO_SUSP_TSTAMP_ACCESS) { cd9660_tstamp_conv7(ptime, &ana->inop->inode.iso_atime); @@ -352,18 +352,18 @@ cd9660_rrip_tstamp(void *v, ISO_RRIP_ANALYZE *ana) } else ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime; - + if (*p->flags & ISO_SUSP_TSTAMP_ATTR) cd9660_tstamp_conv7(ptime, &ana->inop->inode.iso_ctime); else ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime; - + } else { if (*p->flags & ISO_SUSP_TSTAMP_CREAT) ptime += 17; - + if (*p->flags & ISO_SUSP_TSTAMP_MODIFY) { cd9660_tstamp_conv17(ptime, &ana->inop->inode.iso_mtime); @@ -371,7 +371,7 @@ cd9660_rrip_tstamp(void *v, ISO_RRIP_ANALYZE *ana) } else bzero(&ana->inop->inode.iso_mtime, sizeof(struct timespec)); - + if (*p->flags & ISO_SUSP_TSTAMP_ACCESS) { cd9660_tstamp_conv17(ptime, &ana->inop->inode.iso_atime); @@ -379,14 +379,14 @@ cd9660_rrip_tstamp(void *v, ISO_RRIP_ANALYZE *ana) } else ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime; - + if (*p->flags & ISO_SUSP_TSTAMP_ATTR) cd9660_tstamp_conv17(ptime, &ana->inop->inode.iso_ctime); else ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime; - + } ana->fields &= ~ISO_SUSP_TSTAMP; return (ISO_SUSP_TSTAMP); @@ -408,10 +408,10 @@ cd9660_rrip_device(void *v, ISO_RRIP_ANALYZE *ana) { ISO_RRIP_DEVICE *p = v; u_int high, low; - + high = isonum_733(p->dev_t_high); low = isonum_733(p->dev_t_low); - + if (high == 0) ana->inop->inode.iso_rdev = makedev(major(low), minor(low)); else @@ -433,7 +433,7 @@ cd9660_rrip_idflag(void *v, ISO_RRIP_ANALYZE *ana) /* special handling of RE field */ if (ana->fields & ISO_SUSP_RELDIR) return (cd9660_rrip_reldir(p, ana)); - + return (ISO_SUSP_IDFLAG); } @@ -496,7 +496,7 @@ cd9660_rrip_loop(struct iso_directory_record *isodir, ISO_RRIP_ANALYZE *ana, char *pwhead; u_char c; int result; - + /* * Note: If name length is odd, * it will be padded by 1 byte after the name @@ -505,23 +505,23 @@ cd9660_rrip_loop(struct iso_directory_record *isodir, ISO_RRIP_ANALYZE *ana, if (!(isonum_711(isodir->name_len) & 1)) pwhead++; isochar(isodir->name, pwhead, ana->imp->joliet_level, &c); - + /* If it's not the '.' entry of the root dir obey SP field */ if (c != 0 || isonum_733(isodir->extent) != ana->imp->root_extent) pwhead += ana->imp->rr_skip; else pwhead += ana->imp->rr_skip0; - + phead = (ISO_SUSP_HEADER *)pwhead; pend = (ISO_SUSP_HEADER *)((char *)isodir + isonum_711(isodir->length)); - + result = 0; while (1) { ana->iso_ce_len = 0; /* * Note: "pend" should be more than one SUSP header - */ + */ while (pend >= phead + 1) { if (isonum_711(phead->version) == 1) { for (ptable = table; ptable->func; ptable++) { @@ -550,7 +550,7 @@ cd9660_rrip_loop(struct iso_directory_record *isodir, ISO_RRIP_ANALYZE *ana, phead = (ISO_SUSP_HEADER *) ((char *)phead + isonum_711(phead->length)); } - + if (ana->fields && ana->iso_ce_len) { if (ana->iso_ce_blk >= ana->imp->volume_space_size || ana->iso_ce_off + ana->iso_ce_len > @@ -576,7 +576,7 @@ cd9660_rrip_loop(struct iso_directory_record *isodir, ISO_RRIP_ANALYZE *ana, for (ptable = table; ptable->func2; ptable++) if (!(ptable->result & result)) ptable->func2(isodir, ana); - + return (result); } @@ -605,15 +605,15 @@ cd9660_rrip_analyze(struct iso_directory_record *isodir, struct iso_node *inop, struct iso_mnt *imp) { ISO_RRIP_ANALYZE analyze; - + analyze.inop = inop; analyze.imp = imp; analyze.fields = ISO_SUSP_ATTR | ISO_SUSP_TSTAMP | ISO_SUSP_DEVICE; - + return (cd9660_rrip_loop(isodir, &analyze, rrip_table_analyze)); } -/* +/* * Get Alternate Name. */ static RRIP_TABLE rrip_table_getname[] = { @@ -642,7 +642,7 @@ cd9660_rrip_getname(struct iso_directory_record *isodir, char *outbuf, ISO_RRIP_ANALYZE analyze; RRIP_TABLE *tab; u_char c; - + analyze.outbuf = outbuf; analyze.outlen = outlen; analyze.maxlen = NAME_MAX; @@ -651,21 +651,21 @@ cd9660_rrip_getname(struct iso_directory_record *isodir, char *outbuf, analyze.fields = ISO_SUSP_ALTNAME | ISO_SUSP_RELDIR | ISO_SUSP_CLINK | ISO_SUSP_PLINK; *outlen = 0; - + isochar(isodir->name, isodir->name + isonum_711(isodir->name_len), imp->joliet_level, &c); tab = rrip_table_getname; if (c == 0 || c == 1) { cd9660_rrip_defname(isodir, &analyze); - + analyze.fields &= ~ISO_SUSP_ALTNAME; tab++; } - + return (cd9660_rrip_loop(isodir, &analyze, tab)); } -/* +/* * Get Symbolic Link. */ static RRIP_TABLE rrip_table_getsymname[] = { @@ -681,7 +681,7 @@ cd9660_rrip_getsymname(struct iso_directory_record *isodir, char *outbuf, u_short *outlen, struct iso_mnt *imp) { ISO_RRIP_ANALYZE analyze; - + analyze.outbuf = outbuf; analyze.outlen = outlen; *outlen = 0; @@ -689,7 +689,7 @@ cd9660_rrip_getsymname(struct iso_directory_record *isodir, char *outbuf, analyze.cont = 1; /* don't start with a slash */ analyze.imp = imp; analyze.fields = ISO_SUSP_SLINK; - + return (cd9660_rrip_loop(isodir, &analyze, rrip_table_getsymname) & ISO_SUSP_SLINK); } @@ -710,7 +710,7 @@ cd9660_rrip_offset(struct iso_directory_record *isodir, struct iso_mnt *imp) { ISO_RRIP_OFFSET *p; ISO_RRIP_ANALYZE analyze; - + imp->rr_skip0 = 0; p = (ISO_RRIP_OFFSET *)(isodir->name + 1); if (bcmp(p, "SP\7\1\276\357", 6)) { @@ -720,12 +720,12 @@ cd9660_rrip_offset(struct iso_directory_record *isodir, struct iso_mnt *imp) if (bcmp(p, "SP\7\1\276\357", 6)) return (-1); } - + analyze.imp = imp; analyze.fields = ISO_SUSP_EXTREF; if (!(cd9660_rrip_loop(isodir, &analyze, rrip_table_extref) & ISO_SUSP_EXTREF)) return (-1); - + return (isonum_711(p->skip)); } diff --git a/sys/isofs/cd9660/cd9660_util.c b/sys/isofs/cd9660/cd9660_util.c index 60c0cc09f..6763e8334 100644 --- a/sys/isofs/cd9660/cd9660_util.c +++ b/sys/isofs/cd9660/cd9660_util.c @@ -103,7 +103,7 @@ isofncmp(const u_char *fn, int fnlen, const u_char *isofn, int isolen, int i, j; u_char c; const u_char *fnend = fn + fnlen, *isoend = isofn + isolen; - + for (; fn != fnend; fn++) { if (isofn == isoend) return *fn; @@ -161,14 +161,14 @@ isofntrans(u_char *infn, int infnlen, u_char *outfn, u_short *outfnlen, { int fnidx = 0; u_char c, d = '\0', *infnend = infn + infnlen; - + if (assoc) { *outfn++ = ASSOCCHAR; fnidx++; } for (; infn != infnend; fnidx++) { infn += isochar(infn, infnend, joliet_level, &c); - + if (!original && c == ';') { fnidx -= (d == '.'); break; diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index ef0ffbbb1..268ca6550 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vfsops.c,v 1.97 2023/03/08 04:43:08 guenther Exp $ */ +/* $OpenBSD: cd9660_vfsops.c,v 1.98 2023/07/17 09:41:20 semarie Exp $ */ /* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */ /*- @@ -72,7 +72,7 @@ const struct vfsops cd9660_vfsops = { .vfs_fhtovp = cd9660_fhtovp, .vfs_vptofh = cd9660_vptofh, .vfs_init = cd9660_init, - .vfs_sysctl = cd9660_sysctl, + .vfs_sysctl = (void *)eopnotsupp, .vfs_checkexp = cd9660_check_export, }; diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 7f66460e4..2a801b065 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -508,7 +508,7 @@ cd9660_readdir(void *v) if (idp->current.d_namlen == 1 && ep->name[0] == 0) { idp->current.d_namlen = 1; error = iso_uiodir(idp,&idp->current,idp->curroff); - } else if (idp->current.d_namlen == 1 && + } else if (idp->current.d_namlen == 1 && ep->name[0] == 1) { idp->current.d_namlen = 2; error = iso_uiodir(idp,&idp->current,idp->curroff); @@ -614,7 +614,7 @@ cd9660_readlink(void *v) symname = uio->uio_iov->iov_base; else symname = pool_get(&namei_pool, PR_WAITOK); - + /* * Ok, we just gathering a symbolic name in SL record. */ @@ -981,7 +981,7 @@ filt_cd9660read(struct knote *kn, long hint) struct iso_node *node = VTOI(vp); /* - * filesystem is gone, so set the EOF flag and schedule + * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. */ if (hint == NOTE_REVOKE) { @@ -1005,7 +1005,7 @@ int filt_cd9660write(struct knote *kn, long hint) { /* - * filesystem is gone, so set the EOF flag and schedule + * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. */ if (hint == NOTE_REVOKE) { diff --git a/sys/isofs/cd9660/iso.h b/sys/isofs/cd9660/iso.h index 5b9bd4a22..b770ecaf0 100644 --- a/sys/isofs/cd9660/iso.h +++ b/sys/isofs/cd9660/iso.h @@ -212,7 +212,7 @@ isonum_721(u_char *p) } /* 7.2.2: unsigned big-endian 16-bit value. NOT USED IN KERNEL. */ -static __inline int +static __inline int isonum_722(unsigned char *p) { #if !defined(__STRICT_ALIGNMENT) && (BYTE_ORDER == BIG_ENDIAN) @@ -220,7 +220,7 @@ isonum_722(unsigned char *p) #else return ((char)*p << 8)|p[1]; #endif -} +} /* 7.2.3: unsigned both-endian (little, then big) 16-bit value */ static __inline int diff --git a/sys/isofs/udf/ecma167-udf.h b/sys/isofs/udf/ecma167-udf.h index 85980de1e..598687a5a 100644 --- a/sys/isofs/udf/ecma167-udf.h +++ b/sys/isofs/udf/ecma167-udf.h @@ -27,10 +27,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * + * * Extended and adapted for UDFv2.50+ bij Reinoud Zandijk based on the * original by Scott Long. - * + * * 20030508 Made some small typo and explanatory comments * 20030510 Added UDF 2.01 structures * 20030519 Added/correct comments on multi-partitioned logical volume space diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c index c0fc5068e..637061f60 100644 --- a/sys/isofs/udf/udf_vfsops.c +++ b/sys/isofs/udf/udf_vfsops.c @@ -261,7 +261,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) bsize = 2048; /* Should probe the media for its size. */ - /* + /* * Get the Anchor Volume Descriptor Pointer from sector 256. * Should also check sector n - 256, n, and 512. */ @@ -284,7 +284,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) mvds_start = letoh32(avdp.main_vds_ex.loc); mvds_end = mvds_start + (letoh32(avdp.main_vds_ex.len) - 1) / bsize; for (sector = mvds_start; sector < mvds_end; sector++) { - if ((error = bread(devvp, sector * btodb(bsize), bsize, + if ((error = bread(devvp, sector * btodb(bsize), bsize, &bp)) != 0) { printf("Can't read sector %d of VDS\n", sector); goto bail; @@ -308,7 +308,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) ump->um_start = ump->um_realstart = letoh32(pd->start_loc); } - brelse(bp); + brelse(bp); bp = NULL; if ((part_found) && (logvol_found)) break; @@ -371,7 +371,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) */ if (ISSET(ump->um_flags, UDF_MNT_USES_META)) - sector = ump->um_meta_start; + sector = ump->um_meta_start; else sector = fsd_offset; udf_vat_map(ump, §or); @@ -385,7 +385,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) bcopy(&fsd->rootdir_icb, &ump->um_root_icb, sizeof(struct long_ad)); if (ISSET(ump->um_flags, UDF_MNT_USES_META)) { - ump->um_root_icb.loc.lb_num += ump->um_meta_start; + ump->um_root_icb.loc.lb_num += ump->um_meta_start; ump->um_root_icb.loc.part_num = part_num; } } @@ -619,7 +619,7 @@ udf_vget(struct mount *mp, ino_t ino, struct vnode **vpp) bcopy(bp->b_data, up->u_fentry, size + UDF_EXTFENTRY_SIZE); else bcopy(bp->b_data, up->u_fentry, size + UDF_FENTRY_SIZE); - + brelse(bp); bp = NULL; diff --git a/sys/isofs/udf/udf_vnops.c b/sys/isofs/udf/udf_vnops.c index e55770118..aa7f5f08c 100644 --- a/sys/isofs/udf/udf_vnops.c +++ b/sys/isofs/udf/udf_vnops.c @@ -505,7 +505,7 @@ udf_transname(char *cs0string, char *destname, int len, struct umount *ump) } /* - * Compare a CS0 dstring with a name passed in from the VFS layer. Return + * Compare a CS0 dstring with a name passed in from the VFS layer. Return * 0 on a successful match, nonzero otherwise. Unicode work may need to be * done here also. */ @@ -1175,7 +1175,7 @@ udf_reclaim(void *v) pool_put(&unode_pool, up); vp->v_data = NULL; } - + return (0); } @@ -1297,7 +1297,7 @@ udf_bmap_internal(struct unode *up, off_t offset, daddr_t *sector, ad_offset, l_ad); return (EINVAL); } - + if (udf_checktag(&up->u_fentry->tag, TAGID_EXTFENTRY) == 0) icb = GETICB(short_ad, xfentry, l_ea + ad_offset); else diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index 1f61901bb..4721cfd09 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.182 2023/06/10 19:30:48 kettenis Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.183 2023/07/12 19:34:14 jasper Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -325,6 +325,11 @@ elf_load_file(struct proc *p, char *path, struct exec_package *epp, goto bad1; for (i = 0; i < eh.e_phnum; i++) { + if ((ph[i].p_align > 1) && !powerof2(ph[i].p_align)) { + error = EINVAL; + goto bad1; + } + if (ph[i].p_type == PT_LOAD) { if (ph[i].p_filesz > ph[i].p_memsz || ph[i].p_memsz == 0) { @@ -526,6 +531,11 @@ exec_elf_makecmds(struct proc *p, struct exec_package *epp) epp->ep_dsize = ELF_NO_ADDR; for (i = 0, pp = ph; i < eh->e_phnum; i++, pp++) { + if ((pp->p_align > 1) && !powerof2(pp->p_align)) { + error = EINVAL; + goto bad; + } + if (pp->p_type == PT_INTERP && !interp) { if (pp->p_filesz < 2 || pp->p_filesz > MAXPATHLEN) goto bad; @@ -560,7 +570,7 @@ exec_elf_makecmds(struct proc *p, struct exec_package *epp) if (eh->e_type == ET_DYN) { /* need phdr and load sections for PIE */ - if (!has_phdr || base_ph == NULL) { + if (!has_phdr || base_ph == NULL || base_ph->p_vaddr != 0) { error = EINVAL; goto bad; } diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 2622fb4a9..3f3112b01 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.249 2023/07/06 07:49:52 deraadt Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.250 2023/07/10 03:31:57 guenther Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -531,6 +531,11 @@ sys_execve(struct proc *p, void *v, register_t *retval) if (otvp) vrele(otvp); + if (pack.ep_flags & EXEC_NOBTCFI) + atomic_setbits_int(&p->p_p->ps_flags, PS_NOBTCFI); + else + atomic_clearbits_int(&p->p_p->ps_flags, PS_NOBTCFI); + atomic_setbits_int(&pr->ps_flags, PS_EXEC); if (pr->ps_flags & PS_PPWAIT) { atomic_clearbits_int(&pr->ps_flags, PS_PPWAIT); diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 17e00feda..4e3ac5248 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_rwlock.c,v 1.49 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: kern_rwlock.c,v 1.50 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2002, 2003 Artur Grabowski @@ -224,7 +224,6 @@ int rw_enter(struct rwlock *rwl, int flags) { const struct rwlock_op *op; - struct sleep_state sls; unsigned long inc, o; #ifdef MULTIPROCESSOR /* @@ -279,11 +278,11 @@ retry: prio = op->wait_prio; if (flags & RW_INTR) prio |= PCATCH; - sleep_setup(&sls, rwl, prio, rwl->rwl_name); + sleep_setup(rwl, prio, rwl->rwl_name); do_sleep = !rw_cas(&rwl->rwl_owner, o, set); - error = sleep_finish(&sls, prio, 0, do_sleep); + error = sleep_finish(0, do_sleep); if ((flags & RW_INTR) && (error != 0)) return (error); diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 074d58ef5..f92bcec38 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.77 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.79 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski * @@ -248,6 +248,7 @@ setrunqueue(struct cpu_info *ci, struct proc *p, uint8_t prio) KASSERT(ci != NULL); SCHED_ASSERT_LOCKED(); + KASSERT(!ISSET(p->p_flag, P_WSLEEP) || p->p_stat == SSTOP); p->p_cpu = ci; p->p_stat = SRUN; @@ -668,13 +669,12 @@ sched_stop_secondary_cpus(void) } CPU_INFO_FOREACH(cii, ci) { struct schedstate_percpu *spc = &ci->ci_schedstate; - struct sleep_state sls; if (CPU_IS_PRIMARY(ci) || !CPU_IS_RUNNING(ci)) continue; while ((spc->spc_schedflags & SPCF_HALTED) == 0) { - sleep_setup(&sls, spc, PZERO, "schedstate"); - sleep_finish(&sls, PZERO, 0, + sleep_setup(spc, PZERO, "schedstate"); + sleep_finish(0, (spc->spc_schedflags & SPCF_HALTED) == 0); } } diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index a56b7c9f8..ad204e50d 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.307 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.310 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -1151,7 +1151,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type) atomic_clearbits_int(siglist, mask); if (action == SIG_CATCH) goto runfast; - if (p->p_wchan == NULL) + if (p->p_wchan == NULL || p->p_flag & P_WSLEEP) goto run; p->p_stat = SSLEEP; goto out; @@ -1699,7 +1699,7 @@ coredump(struct proc *p) } /* incrash should be 0 or KERNELPATH only */ - NDINIT(&nd, 0, incrash, UIO_SYSSPACE, name, p); + NDINIT(&nd, 0, BYPASSUNVEIL | incrash, UIO_SYSSPACE, name, p); error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW | O_NONBLOCK, S_IRUSR | S_IWUSR); @@ -2164,15 +2164,14 @@ single_thread_set(struct proc *p, enum single_thread_mode mode, int wait) int single_thread_wait(struct process *pr, int recheck) { - struct sleep_state sls; int wait; /* wait until they're all suspended */ wait = pr->ps_singlecount > 0; while (wait) { - sleep_setup(&sls, &pr->ps_singlecount, PWAIT, "suspend"); + sleep_setup(&pr->ps_singlecount, PWAIT, "suspend"); wait = pr->ps_singlecount > 0; - sleep_finish(&sls, PWAIT, 0, wait); + sleep_finish(0, wait); if (!recheck) break; } @@ -2204,7 +2203,7 @@ single_thread_clear(struct proc *p, int flag) * it back into some sleep queue */ if (q->p_stat == SSTOP && (q->p_flag & flag) == 0) { - if (q->p_wchan == NULL) + if (p->p_wchan == NULL || p->p_flag & P_WSLEEP) setrunnable(q); else q->p_stat = SSLEEP; diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index e6e1a4720..d4087b5fc 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.193 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.195 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -115,7 +115,6 @@ extern int safepri; int tsleep(const volatile void *ident, int priority, const char *wmesg, int timo) { - struct sleep_state sls; #ifdef MULTIPROCESSOR int hold_count; #endif @@ -151,8 +150,8 @@ tsleep(const volatile void *ident, int priority, const char *wmesg, int timo) return (0); } - sleep_setup(&sls, ident, priority, wmesg); - return sleep_finish(&sls, priority, timo, 1); + sleep_setup(ident, priority, wmesg); + return sleep_finish(timo, 1); } int @@ -206,7 +205,6 @@ int msleep(const volatile void *ident, struct mutex *mtx, int priority, const char *wmesg, int timo) { - struct sleep_state sls; int error, spl; #ifdef MULTIPROCESSOR int hold_count; @@ -244,23 +242,14 @@ msleep(const volatile void *ident, struct mutex *mtx, int priority, return (0); } - sleep_setup(&sls, ident, priority, wmesg); + sleep_setup(ident, priority, wmesg); - /* XXX - We need to make sure that the mutex doesn't - * unblock splsched. This can be made a bit more - * correct when the sched_lock is a mutex. - */ - spl = MUTEX_OLDIPL(mtx); - MUTEX_OLDIPL(mtx) = splsched(); mtx_leave(mtx); /* signal may stop the process, release mutex before that */ - error = sleep_finish(&sls, priority, timo, 1); + error = sleep_finish(timo, 1); - if ((priority & PNORELOCK) == 0) { + if ((priority & PNORELOCK) == 0) mtx_enter(mtx); - MUTEX_OLDIPL(mtx) = spl; /* put the ipl back */ - } else - splx(spl); return error; } @@ -296,19 +285,19 @@ int rwsleep(const volatile void *ident, struct rwlock *rwl, int priority, const char *wmesg, int timo) { - struct sleep_state sls; int error, status; KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0); KASSERT(ident != &nowake || ISSET(priority, PCATCH) || timo != 0); + KASSERT(ident != rwl); rw_assert_anylock(rwl); status = rw_status(rwl); - sleep_setup(&sls, ident, priority, wmesg); + sleep_setup(ident, priority, wmesg); rw_exit(rwl); /* signal may stop the process, release rwlock before that */ - error = sleep_finish(&sls, priority, timo, 1); + error = sleep_finish(timo, 1); if ((priority & PNORELOCK) == 0) rw_enter(rwl, status); @@ -340,10 +329,10 @@ rwsleep_nsec(const volatile void *ident, struct rwlock *rwl, int priority, } void -sleep_setup(struct sleep_state *sls, const volatile void *ident, int prio, - const char *wmesg) +sleep_setup(const volatile void *ident, int prio, const char *wmesg) { struct proc *p = curproc; + int s; #ifdef DIAGNOSTIC if (p->p_flag & P_CANTSLEEP) @@ -354,7 +343,7 @@ sleep_setup(struct sleep_state *sls, const volatile void *ident, int prio, panic("tsleep: not SONPROC"); #endif - SCHED_LOCK(sls->sls_s); + SCHED_LOCK(s); TRACEPOINT(sched, sleep, NULL); @@ -362,23 +351,29 @@ sleep_setup(struct sleep_state *sls, const volatile void *ident, int prio, p->p_wmesg = wmesg; p->p_slptime = 0; p->p_slppri = prio & PRIMASK; + atomic_setbits_int(&p->p_flag, P_WSLEEP); TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_runq); + if (prio & PCATCH) + atomic_setbits_int(&p->p_flag, P_SINTR); + p->p_stat = SSLEEP; + SCHED_UNLOCK(s); } int -sleep_finish(struct sleep_state *sls, int prio, int timo, int do_sleep) +sleep_finish(int timo, int do_sleep) { struct proc *p = curproc; - int catch, error = 0, error1 = 0; + int s, catch, error = 0, error1 = 0; - catch = prio & PCATCH; + catch = p->p_flag & P_SINTR; if (timo != 0) { KASSERT((p->p_flag & P_TIMEOUT) == 0); timeout_add(&p->p_sleep_to, timo); } + SCHED_LOCK(s); if (catch != 0) { /* * We put ourselves on the sleep queue and start our @@ -388,28 +383,28 @@ sleep_finish(struct sleep_state *sls, int prio, int timo, int do_sleep) * us to be marked as SSLEEP without resuming us, thus * we must be ready for sleep when sleep_signal_check() is * called. - * If the wakeup happens while we're stopped, p->p_wchan - * will be NULL upon return from sleep_signal_check(). In - * that case we need to unwind immediately. */ - atomic_setbits_int(&p->p_flag, P_SINTR); if ((error = sleep_signal_check()) != 0) { - p->p_stat = SONPROC; - catch = 0; - do_sleep = 0; - } else if (p->p_wchan == NULL) { catch = 0; do_sleep = 0; } } + /* + * If the wakeup happens while going to sleep, p->p_wchan + * will be NULL. In that case unwind immediately but still + * check for possible signals and timeouts. + */ + if (p->p_wchan == NULL) + do_sleep = 0; + + atomic_clearbits_int(&p->p_flag, P_WSLEEP); if (do_sleep) { - p->p_stat = SSLEEP; p->p_ru.ru_nvcsw++; - SCHED_ASSERT_LOCKED(); mi_switch(); } else { unsleep(p); + p->p_stat = SONPROC; } #ifdef DIAGNOSTIC @@ -418,7 +413,7 @@ sleep_finish(struct sleep_state *sls, int prio, int timo, int do_sleep) #endif p->p_cpu->ci_schedstate.spc_curpriority = p->p_usrpri; - SCHED_UNLOCK(sls->sls_s); + SCHED_UNLOCK(s); /* * Even though this belongs to the signal handling part of sleep, @@ -482,8 +477,12 @@ wakeup_proc(struct proc *p, const volatile void *chan, int flags) atomic_setbits_int(&p->p_flag, flags); if (p->p_stat == SSLEEP) setrunnable(p); - else + else if (p->p_stat == SSTOP) unsleep(p); +#ifdef DIAGNOSTIC + else + panic("wakeup: p_stat is %d", (int)p->p_stat); +#endif } return awakened; @@ -538,12 +537,6 @@ wakeup_n(const volatile void *ident, int n) qp = &slpque[LOOKUP(ident)]; for (p = TAILQ_FIRST(qp); p != NULL && n != 0; p = pnext) { pnext = TAILQ_NEXT(p, p_runq); - /* - * This happens if wakeup(9) is called after enqueuing - * itself on the sleep queue and both `ident' collide. - */ - if (p == curproc) - continue; #ifdef DIAGNOSTIC if (p->p_stat != SSLEEP && p->p_stat != SSTOP) panic("wakeup: p_stat is %d", (int)p->p_stat); @@ -828,7 +821,6 @@ refcnt_rele_wake(struct refcnt *r) void refcnt_finalize(struct refcnt *r, const char *wmesg) { - struct sleep_state sls; u_int refs; membar_exit_before_atomic(); @@ -836,9 +828,9 @@ refcnt_finalize(struct refcnt *r, const char *wmesg) KASSERT(refs != ~0); TRACEINDEX(refcnt, r->r_traceidx, r, refs + 1, -1); while (refs) { - sleep_setup(&sls, r, PWAIT, wmesg); + sleep_setup(r, PWAIT, wmesg); refs = atomic_load_int(&r->r_refs); - sleep_finish(&sls, PWAIT, 0, refs); + sleep_finish(0, refs); } TRACEINDEX(refcnt, r->r_traceidx, r, refs, 0); /* Order subsequent loads and stores after refs == 0 load. */ @@ -882,13 +874,12 @@ cond_signal(struct cond *c) void cond_wait(struct cond *c, const char *wmesg) { - struct sleep_state sls; unsigned int wait; wait = atomic_load_int(&c->c_wait); while (wait) { - sleep_setup(&sls, c, PWAIT, wmesg); + sleep_setup(c, PWAIT, wmesg); wait = atomic_load_int(&c->c_wait); - sleep_finish(&sls, PWAIT, 0, wait); + sleep_finish(0, wait); } } diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index ee235e8cc..5fe1a2f24 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.417 2023/07/07 16:27:46 bluhm Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.418 2023/07/16 03:01:31 yasuoka Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -515,22 +515,20 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case KERN_MBSTAT: { extern struct cpumem *mbstat; uint64_t counters[MBSTAT_COUNT]; - struct mbstat *mbs; + struct mbstat mbs; unsigned int i; - int ret; - mbs = malloc(sizeof(*mbs), M_TEMP, M_WAITOK | M_ZERO); + memset(&mbs, 0, sizeof(mbs)); counters_read(mbstat, counters, MBSTAT_COUNT); for (i = 0; i < MBSTAT_TYPES; i++) - mbs->m_mtypes[i] = counters[i]; + mbs.m_mtypes[i] = counters[i]; - mbs->m_drops = counters[MBSTAT_DROPS]; - mbs->m_wait = counters[MBSTAT_WAIT]; - mbs->m_drain = counters[MBSTAT_DRAIN]; + mbs.m_drops = counters[MBSTAT_DROPS]; + mbs.m_wait = counters[MBSTAT_WAIT]; + mbs.m_drain = counters[MBSTAT_DRAIN]; - ret = sysctl_rdstruct(oldp, oldlenp, newp, mbs, sizeof(*mbs)); - free(mbs, M_TEMP, sizeof(*mbs)); - return (ret); + return (sysctl_rdstruct(oldp, oldlenp, newp, + &mbs, sizeof(mbs))); } case KERN_MSGBUFSIZE: case KERN_CONSBUFSIZE: { diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index a99417b66..b17f17ca1 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_timeout.c,v 1.93 2023/07/06 23:24:37 cheloha Exp $ */ +/* $OpenBSD: kern_timeout.c,v 1.94 2023/07/14 07:07:08 claudio Exp $ */ /* * Copyright (c) 2001 Thomas Nordin * Copyright (c) 2000-2001 Artur Grabowski @@ -735,7 +735,6 @@ softclock_thread(void *arg) { CPU_INFO_ITERATOR cii; struct cpu_info *ci; - struct sleep_state sls; struct timeout *to; int s; @@ -751,8 +750,8 @@ softclock_thread(void *arg) s = splsoftclock(); for (;;) { - sleep_setup(&sls, &timeout_proc, PSWP, "bored"); - sleep_finish(&sls, PSWP, 0, CIRCQ_EMPTY(&timeout_proc)); + sleep_setup(&timeout_proc, PSWP, "bored"); + sleep_finish(0, CIRCQ_EMPTY(&timeout_proc)); mtx_enter(&timeout_mutex); while (!CIRCQ_EMPTY(&timeout_proc)) { diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c index 753edaed6..cdb208272 100644 --- a/sys/kern/sched_bsd.c +++ b/sys/kern/sched_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sched_bsd.c,v 1.76 2023/06/21 21:16:21 cheloha Exp $ */ +/* $OpenBSD: sched_bsd.c,v 1.77 2023/07/11 07:02:43 claudio Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -440,6 +440,10 @@ setrunnable(struct proc *p) case SSLEEP: prio = p->p_slppri; unsleep(p); /* e.g. when sending signals */ + + /* if not yet asleep, don't add to runqueue */ + if (ISSET(p->p_flag, P_WSLEEP)) + return; break; } setrunqueue(NULL, p, prio); diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 1f4ae515b..12bd44e7c 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.76 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: subr_log.c,v 1.77 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -233,7 +233,6 @@ logclose(dev_t dev, int flag, int mode, struct proc *p) int logread(dev_t dev, struct uio *uio, int flag) { - struct sleep_state sls; struct msgbuf *mbp = msgbufp; size_t l, rpos; int error = 0; @@ -250,9 +249,8 @@ logread(dev_t dev, struct uio *uio, int flag) * Set up and enter sleep manually instead of using msleep() * to keep log_mtx as a leaf lock. */ - sleep_setup(&sls, mbp, LOG_RDPRI | PCATCH, "klog"); - error = sleep_finish(&sls, LOG_RDPRI | PCATCH, 0, - logsoftc.sc_state & LOG_RDWAIT); + sleep_setup(mbp, LOG_RDPRI | PCATCH, "klog"); + error = sleep_finish(0, logsoftc.sc_state & LOG_RDWAIT); mtx_enter(&log_mtx); if (error) goto out; diff --git a/sys/kern/subr_suspend.c b/sys/kern/subr_suspend.c index 833c918d9..1b4f40629 100644 --- a/sys/kern/subr_suspend.c +++ b/sys/kern/subr_suspend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_suspend.c,v 1.15 2023/07/02 19:02:27 cheloha Exp $ */ +/* $OpenBSD: subr_suspend.c,v 1.16 2023/07/12 18:40:06 cheloha Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -26,6 +26,9 @@ #include #include #include +#ifdef GPROF +#include +#endif #ifdef HIBERNATE #include #endif @@ -49,6 +52,9 @@ sleep_state(void *v, int sleepmode) extern int perflevel; size_t rndbuflen; char *rndbuf; +#ifdef GPROF + int gmon_state; +#endif #if NSOFTRAID > 0 extern void sr_quiesce(void); #endif @@ -100,6 +106,12 @@ top: #ifdef MULTIPROCESSOR sched_stop_secondary_cpus(); KASSERT(CPU_IS_PRIMARY(curcpu())); +#endif +#ifdef GPROF + gmon_state = gmoninit; + gmoninit = 0; +#endif +#ifdef MULTIPROCESSOR sleep_mp(); #endif @@ -172,6 +184,11 @@ fail_suspend: resume_randomness(rndbuf, rndbuflen); #ifdef MULTIPROCESSOR resume_mp(); +#endif +#ifdef GPROF + gmoninit = gmon_state; +#endif +#ifdef MULTIPROCESSOR sched_start_secondary_cpus(); #endif vfs_stall(curproc, 0); diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index e6a175e9f..765b70a09 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vnops.c,v 1.121 2022/08/14 01:58:28 jsg Exp $ */ +/* $OpenBSD: vfs_vnops.c,v 1.122 2023/07/10 22:54:40 deraadt Exp $ */ /* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */ /* @@ -86,13 +86,13 @@ vn_open(struct nameidata *ndp, int fmode, int cmode) int error; /* - * The only valid flag to pass in here from NDINIT is - * KERNELPATH, This function will override the nameiop based - * on the fmode and cmode flags, So validate that our caller - * has not set other flags or operations in the nameidata + * The only valid flags to pass in here from NDINIT are + * KERNELPATH or BYPASSUNVEIL. This function will override the + * nameiop based on the fmode and cmode flags, so validate that + * our caller has not set other flags or operations in the nameidata * structure. */ - KASSERT(ndp->ni_cnd.cn_flags == 0 || ndp->ni_cnd.cn_flags == KERNELPATH); + KASSERT((ndp->ni_cnd.cn_flags & ~(KERNELPATH|BYPASSUNVEIL)) == 0); KASSERT(ndp->ni_cnd.cn_nameiop == 0); if ((fmode & (FREAD|FWRITE)) == 0) diff --git a/sys/lib/libkern/bcmp.c b/sys/lib/libkern/bcmp.c index 6e7585eb0..8d82e584f 100644 --- a/sys/lib/libkern/bcmp.c +++ b/sys/lib/libkern/bcmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcmp.c,v 1.13 2021/05/16 04:51:00 jsg Exp $ */ +/* $OpenBSD: bcmp.c,v 1.14 2023/07/13 20:33:30 millert Exp $ */ /* * Copyright (c) 1987 Regents of the University of California. @@ -42,12 +42,12 @@ bcmp(const void *b1, const void *b2, size_t length) char *p1, *p2; if (length == 0) - return(0); + return (0); p1 = (char *)b1; p2 = (char *)b2; do if (*p1++ != *p2++) - break; + return (1); while (--length); - return(length); + return (0); } diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c index 0de37665d..5b27bb778 100644 --- a/sys/msdosfs/msdosfs_vfsops.c +++ b/sys/msdosfs/msdosfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vfsops.c,v 1.96 2022/08/12 14:30:52 visa Exp $ */ +/* $OpenBSD: msdosfs_vfsops.c,v 1.97 2023/07/17 09:41:20 semarie Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.48 1997/10/18 02:54:57 briggs Exp $ */ /*- @@ -762,27 +762,18 @@ msdosfs_check_export(struct mount *mp, struct mbuf *nam, int *exflagsp, return (0); } -#define msdosfs_vget ((int (*)(struct mount *, ino_t, struct vnode **)) \ - eopnotsupp) - -#define msdosfs_quotactl ((int (*)(struct mount *, int, uid_t, caddr_t, \ - struct proc *))eopnotsupp) - -#define msdosfs_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \ - size_t, struct proc *))eopnotsupp) - const struct vfsops msdosfs_vfsops = { .vfs_mount = msdosfs_mount, .vfs_start = msdosfs_start, .vfs_unmount = msdosfs_unmount, .vfs_root = msdosfs_root, - .vfs_quotactl = msdosfs_quotactl, + .vfs_quotactl = (void *)eopnotsupp, .vfs_statfs = msdosfs_statfs, .vfs_sync = msdosfs_sync, - .vfs_vget = msdosfs_vget, + .vfs_vget = (void *)eopnotsupp, .vfs_fhtovp = msdosfs_fhtovp, .vfs_vptofh = msdosfs_vptofh, .vfs_init = msdosfs_init, - .vfs_sysctl = msdosfs_sysctl, + .vfs_sysctl = (void *)eopnotsupp, .vfs_checkexp = msdosfs_check_export, }; diff --git a/sys/net/bfd.c b/sys/net/bfd.c index bbc58a040..19e53cf6e 100644 --- a/sys/net/bfd.c +++ b/sys/net/bfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bfd.c,v 1.78 2021/09/14 09:15:55 mvs Exp $ */ +/* $OpenBSD: bfd.c,v 1.79 2023/07/12 16:10:45 mvs Exp $ */ /* * Copyright (c) 2016-2018 Peter Hessler @@ -436,7 +436,6 @@ bfd_listener(struct bfd_config *bfd, unsigned int port) struct socket *so; struct mbuf *m = NULL, *mopt = NULL; int *ip, error; - int s; /* sa_family and sa_len must be equal */ if (src->sa_family != dst->sa_family || src->sa_len != dst->sa_len) @@ -453,9 +452,9 @@ bfd_listener(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = MAXTTL; - s = solock(so); + solock(so); error = sosetopt(so, IPPROTO_IP, IP_MINTTL, mopt); - sounlock(so, s); + sounlock(so); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -480,9 +479,9 @@ bfd_listener(struct bfd_config *bfd, unsigned int port) break; } - s = solock(so); + solock(so); error = sobind(so, m, p); - sounlock(so, s); + sounlock(so); if (error) { printf("%s: sobind error %d\n", __func__, error); @@ -518,7 +517,6 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) struct sockaddr_in6 *sin6; struct sockaddr_in *sin; int error, *ip; - int s; /* sa_family and sa_len must be equal */ if (src->sa_family != dst->sa_family || src->sa_len != dst->sa_len) @@ -533,9 +531,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = IP_PORTRANGE_HIGH; - s = solock(so); + solock(so); error = sosetopt(so, IPPROTO_IP, IP_PORTRANGE, mopt); - sounlock(so, s); + sounlock(so); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -547,9 +545,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = MAXTTL; - s = solock(so); + solock(so); error = sosetopt(so, IPPROTO_IP, IP_TTL, mopt); - sounlock(so, s); + sounlock(so); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -561,9 +559,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) mopt->m_len = sizeof(int); ip = mtod(mopt, int *); *ip = IPTOS_PREC_INTERNETCONTROL; - s = solock(so); + solock(so); error = sosetopt(so, IPPROTO_IP, IP_TOS, mopt); - sounlock(so, s); + sounlock(so); m_freem(mopt); if (error) { printf("%s: sosetopt error %d\n", @@ -588,9 +586,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) break; } - s = solock(so); + solock(so); error = sobind(so, m, p); - sounlock(so, s); + sounlock(so); if (error) { printf("%s: sobind error %d\n", __func__, error); @@ -611,9 +609,9 @@ bfd_sender(struct bfd_config *bfd, unsigned int port) break; } - s = solock(so); + solock(so); error = soconnect(so, m); - sounlock(so, s); + sounlock(so); if (error && error != ECONNREFUSED) { printf("%s: soconnect error %d\n", __func__, error); diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 93e99a796..516ee5312 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -798,7 +798,7 @@ gif_input(struct gif_tunnel *key, struct mbuf **mp, int *offp, int proto, m->m_flags &= ~M_TUNNEL; return (-1); } - + key->t_rtableid = m->m_pkthdr.ph_rtableid; sc = gif_find(key); @@ -864,7 +864,7 @@ gif_input(struct gif_tunnel *key, struct mbuf **mp, int *offp, int proto, shim = *mtod(m, uint32_t *) & MPLS_EXP_MASK; itos = (ntohl(shim) >> MPLS_EXP_OFFSET) << 5; - + m->m_pkthdr.ph_family = AF_MPLS; break; } diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 112fda79f..7610ac61c 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_loop.c,v 1.95 2023/07/02 19:59:15 bluhm Exp $ */ +/* $OpenBSD: if_loop.c,v 1.96 2023/07/18 16:01:20 bluhm Exp $ */ /* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */ /* @@ -172,11 +172,11 @@ loop_clone_create(struct if_clone *ifc, int unit) ifp->if_softc = NULL; ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; - ifp->if_xflags = IFXF_CLONED; + ifp->if_xflags = IFXF_CLONED | IFXF_LRO; ifp->if_capabilities = IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4 | IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6 | - IFCAP_LRO; + IFCAP_LRO | IFCAP_TSOv4 | IFCAP_TSOv6; ifp->if_rtrequest = lortrequest; ifp->if_ioctl = loioctl; ifp->if_input = loinput; diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c index bf685712e..0e232fefa 100644 --- a/sys/net/if_pfsync.c +++ b/sys/net/if_pfsync.c @@ -1265,7 +1265,7 @@ struct pfsync_q { static struct pfsync_slice * pfsync_slice_enter(struct pfsync_softc *sc, const struct pf_state *st) { - unsigned int idx = st->key[0]->hash % nitems(sc->sc_slices); + unsigned int idx = st->key[0]->hash % nitems(sc->sc_slices); struct pfsync_slice *s = &sc->sc_slices[idx]; if (!mtx_enter_try(&s->s_mtx)) { diff --git a/sys/net/if_pfsync.h b/sys/net/if_pfsync.h index e83ddd830..6b6ccbd6b 100644 --- a/sys/net/if_pfsync.h +++ b/sys/net/if_pfsync.h @@ -188,7 +188,7 @@ struct pfsync_del_c { u_int32_t creatorid; } __packed; -/* +/* * INS_F, DEL_F */ diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 66826738b..395394275 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -617,7 +617,7 @@ pppx_if_find(struct pppx_dev *pxd, int session_id, int protocol) if ((pxi = pppx_if_find_locked(pxd, session_id, protocol))) refcnt_take(&pxi->pxi_refcnt); - + return pxi; } diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index 1efc8ab43..c61f4ac1d 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -760,14 +760,14 @@ trunk_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case TRUNK_OPT_LACP_SYS_PRIO: if (tro->to_lacpopts.lacp_prio == 0) { - error = EINVAL; + error = EINVAL; break; } lsc->lsc_sys_prio = tro->to_lacpopts.lacp_prio; break; case TRUNK_OPT_LACP_PORT_PRIO: if (tro->to_lacpopts.lacp_portprio == 0) { - error = EINVAL; + error = EINVAL; break; } lsc->lsc_port_prio = @@ -776,7 +776,7 @@ trunk_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case TRUNK_OPT_LACP_IFQ_PRIO: if (tro->to_lacpopts.lacp_ifqprio > IFQ_MAXPRIO) { - error = EINVAL; + error = EINVAL; break; } lsc->lsc_ifq_prio = diff --git a/sys/net/if_wg.c b/sys/net/if_wg.c index 951cb6f1d..d9aadc3b9 100644 --- a/sys/net/if_wg.c +++ b/sys/net/if_wg.c @@ -1577,7 +1577,7 @@ wg_decap(struct wg_softc *sc, struct mbuf *m) peer = t->t_peer; /* - * Likewise to wg_encap, we pass a buf and buf length to + * Likewise to wg_encap, we pass a buf and buf length to * noise_remote_decrypt. Again, possible to teach it about mbufs * but need to get over the p_decap_queue situation first. However, * we do not need to allocate a new mbuf as the decrypted packet is diff --git a/sys/net/ifq.c b/sys/net/ifq.c index 9010a3463..3fed3e6dc 100644 --- a/sys/net/ifq.c +++ b/sys/net/ifq.c @@ -824,7 +824,7 @@ ifiq_process(void *arg) } int -net_ifiq_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, +net_ifiq_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { int error = EOPNOTSUPP; diff --git a/sys/net/pf.c b/sys/net/pf.c index eb233a8af..d7912d00e 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1596,11 +1596,11 @@ pf_purge_states_tick(void *null) timeout_add_sec(&pf_purge_states_to, 1); return; } - + /* * process a fraction of the state table every second */ - + if (interval > 1) limit /= interval; @@ -1653,12 +1653,12 @@ pf_purge(void *null) pf_purge_expired_src_nodes(); PF_UNLOCK(); - + /* * Fragments don't require PF_LOCK(), they use their own lock. */ pf_purge_expired_fragments(); - + /* interpret the interval as idle time between runs */ timeout_add_sec(&pf_purge_to, interval); } diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c index 046cc818b..97f0af7bc 100644 --- a/sys/net/pf_if.c +++ b/sys/net/pf_if.c @@ -411,7 +411,7 @@ void pfi_group_addmember(const char *group) { PF_LOCK(); - pfi_group_change(group); + pfi_group_change(group); pfi_xcommit(); PF_UNLOCK(); } diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c index 078fa72e0..e44b80c6d 100644 --- a/sys/net/pf_ioctl.c +++ b/sys/net/pf_ioctl.c @@ -1947,7 +1947,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) break; } - case DIOCGETSTATES: + case DIOCGETSTATES: error = pf_states_get((struct pfioc_states *)addr); break; diff --git a/sys/net/pf_lb.c b/sys/net/pf_lb.c index 7bd6dfd60..4a6ae94ec 100644 --- a/sys/net/pf_lb.c +++ b/sys/net/pf_lb.c @@ -564,7 +564,7 @@ pf_map_addr(sa_family_t af, struct pf_rule *r, struct pf_addr *saddr, break; pf_addr_inc(&rpool->counter, af); } while (1); - + weight = rpool->weight; } diff --git a/sys/net/pf_syncookies.c b/sys/net/pf_syncookies.c index d6691b8e9..bc06cbfc3 100644 --- a/sys/net/pf_syncookies.c +++ b/sys/net/pf_syncookies.c @@ -43,7 +43,7 @@ * We leave synflood mode when the number of half-open states - including * in-flight syncookies - drops far enough again */ - + /* * syncookie enabled Initial Sequence Number: * 24 bit MAC @@ -284,7 +284,7 @@ pf_syncookie_newkey(void) * [An Analysis of TCP Maximum Segment Sizes, S. Alcock and R. Nelson, 2011] * .2% .3% 5% 7% 7% 20% 15% 45% */ -static int pf_syncookie_msstab[] = +static int pf_syncookie_msstab[] = { 216, 536, 1200, 1360, 1400, 1440, 1452, 1460 }; /* diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index cdc5ce2b2..cf076d2b7 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -367,7 +367,7 @@ pfkeyv2_send(struct socket *so, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; goto out; } - + if (nam) { error = EISCONN; goto out; diff --git a/sys/net/pfvar_priv.h b/sys/net/pfvar_priv.h index 53d983432..ee4302e4b 100644 --- a/sys/net/pfvar_priv.h +++ b/sys/net/pfvar_priv.h @@ -153,7 +153,7 @@ extern struct pf_state_tree_id tree_id; * - pfsync bulk send operations * - bulk state fetches via the DIOCGETSTATES ioctl * - bulk state clearing via the DIOCCLRSTATES ioctl - * + * * states are inserted into the global pf_state_list once it has also * been successfully added to the various trees that make up the state * table. states are only removed from the pf_state_list by the garbage @@ -212,7 +212,7 @@ extern struct pf_state_tree_id tree_id; * rw_exit_read(&pf_state_list.pfs_rwl); * * removing an item from the list: - * + * * // wait for iterators (readers) to get out * rw_enter_write(&pf_state_list.pfs_rwl); * diff --git a/sys/net/pipex.c b/sys/net/pipex.c index 3a1a524c6..6b7944c62 100644 --- a/sys/net/pipex.c +++ b/sys/net/pipex.c @@ -941,7 +941,7 @@ again: #if NBPFILTER > 0 { struct ifnet *ifp; - + if ((ifp = if_get(session->ifindex)) != NULL) { if (ifp->if_bpf && ifp->if_type == IFT_PPP) bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_IN); @@ -1585,7 +1585,7 @@ pipex_pptp_input(struct mbuf *m0, struct pipex_session *session) * deep within if the packet will be consumed. In the error * path lock will be held all the time. So increment `rcv_gap' * here, and on the error path back it out, no atomicity will - * be lost in all cases. + * be lost in all cases. */ if (!rewind) session->proto.pptp.rcv_gap += nseq; @@ -2068,7 +2068,7 @@ pipex_l2tp_input(struct mbuf *m0, int off0, struct pipex_session *session, * deep within if the packet will be consumed. In the error * path lock will be held all the time. So increment `nr_gap' * here, and on the error path back it out, no atomicity will - * be lost in all cases. + * be lost in all cases. */ if (!rewind) session->proto.l2tp.nr_gap += nseq; @@ -2520,7 +2520,7 @@ pipex_mppe_input(struct mbuf *m0, struct pipex_session *session) /* Send CCP ResetReq */ PIPEX_DBG((session, LOG_DEBUG, "CCP SendResetReq")); - + mtx_enter(&session->pxs_mtx); ccp_id = session->ccp_id; session->ccp_id++; diff --git a/sys/net/pipex_local.h b/sys/net/pipex_local.h index 5a6264d82..90b727d56 100644 --- a/sys/net/pipex_local.h +++ b/sys/net/pipex_local.h @@ -205,7 +205,7 @@ struct pipex_session { int ccp_id; /* [s] CCP packet id */ struct pipex_mppe mppe_recv, /* MPPE context for incoming */ - mppe_send; /* MPPE context for outgoing */ + mppe_send; /* MPPE context for outgoing */ #endif /*PIPEXMPPE */ struct cpumem *stat_counters; diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index 74fb5bda3..a881e7fae 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -1107,7 +1107,7 @@ enum { */ enum ieee80211_htprot { IEEE80211_HTPROT_NONE = 0, /* only 20/40MHz HT STAs exist */ - IEEE80211_HTPROT_NONMEMBER, /* non-HT STA overlaps our channel */ + IEEE80211_HTPROT_NONMEMBER, /* non-HT STA overlaps our channel */ IEEE80211_HTPROT_20MHZ, /* 20MHz HT STA on a 40MHz channel */ IEEE80211_HTPROT_NONHT_MIXED /* non-HT STA associated to our BSS */ }; diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h index 748b44b3f..513c0f285 100644 --- a/sys/net80211/ieee80211_crypto.h +++ b/sys/net80211/ieee80211_crypto.h @@ -55,7 +55,7 @@ enum ieee80211_akm { #define IEEE80211_PMK_LEN 32 -#ifdef _KERNEL +#ifdef _KERNEL static __inline int ieee80211_is_8021x_akm(enum ieee80211_akm akm) diff --git a/sys/net80211/ieee80211_crypto_ccmp.c b/sys/net80211/ieee80211_crypto_ccmp.c index 38f933977..3b48d58e0 100644 --- a/sys/net80211/ieee80211_crypto_ccmp.c +++ b/sys/net80211/ieee80211_crypto_ccmp.c @@ -114,7 +114,7 @@ ieee80211_ccmp_phase1(AES_CTX *ctx, const struct ieee80211_frame *wh, aad += IEEE80211_ADDR_LEN; } if (ieee80211_has_qos(wh)) { - /* + /* * XXX 802.11-2012 11.4.3.3.3 g says the A-MSDU present bit * must be set here if both STAs are SPP A-MSDU capable. */ diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index ff43a9a80..e59ee178f 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -167,7 +167,7 @@ ieee80211_input_hwdecrypt(struct ieee80211com *ic, struct ieee80211_node *ni, k = ieee80211_get_rxkey(ic, m, ni); if (k == NULL) return NULL; - + wh = mtod(m, struct ieee80211_frame *); hdrlen = ieee80211_get_hdrlen(wh); @@ -343,7 +343,7 @@ ieee80211_inputm(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, } } #endif - /* + /* * If Block Ack was explicitly requested, check * if we have a BA agreement for this RA/TID. */ @@ -359,7 +359,7 @@ ieee80211_inputm(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, goto err; } - /* + /* * Check if we have an explicit or implicit * Block Ack Request for a valid BA agreement. */ @@ -841,11 +841,11 @@ ieee80211_input_ba(struct ieee80211com *ic, struct mbuf *m, ic->ic_stats.is_ht_rx_frame_above_ba_winend++; count = (sn - ba->ba_winend) & 0xfff; if (count > ba->ba_winsize) { - /* + /* * Check whether we're consistently behind the window, * and let the window move forward if necessary. */ - if (ba->ba_winmiss < IEEE80211_BA_MAX_WINMISS) { + if (ba->ba_winmiss < IEEE80211_BA_MAX_WINMISS) { if (ba->ba_missedsn == ((sn - 1) & 0xfff)) ba->ba_winmiss++; else @@ -893,7 +893,7 @@ ieee80211_input_ba(struct ieee80211com *ic, struct mbuf *m, ieee80211_input_ba_flush(ic, ni, ba, ml); } -/* +/* * Forward buffered frames with sequence number lower than max_seq. * See 802.11-2012 9.21.7.6.2 b. */ @@ -961,7 +961,7 @@ ieee80211_input_ba_flush(struct ieee80211com *ic, struct ieee80211_node *ni, timeout_add_msec(&ba->ba_gap_to, IEEE80211_BA_GAP_TIMEOUT); } -/* +/* * Forcibly move the BA window forward to remove a leading gap which has * been causing frames to linger in the reordering buffer for too long. * A leading gap will occur if a particular A-MPDU subframe never arrives @@ -1004,7 +1004,7 @@ ieee80211_input_ba_gap_timeout(void *arg) if_input(&ic->ic_if, &ml); } - splx(s); + splx(s); } @@ -1182,7 +1182,7 @@ ieee80211_amsdu_decap_validate(struct ieee80211com *ic, struct mbuf *m, const uint8_t llc_hdr_mac[ETHER_ADDR_LEN] = { /* MAC address matching the 802.2 LLC header. */ LLC_SNAP_LSAP, LLC_SNAP_LSAP, LLC_UI, 0, 0, 0 - }; + }; /* * We are sorry, but this particular MAC address cannot be used. @@ -1299,13 +1299,13 @@ ieee80211_amsdu_decap(struct ieee80211com *ic, struct mbuf *m, } ml_enqueue(&subframes, m); - + m = n; /* remove padding */ pad = ((len + 3) & ~3) - len; m_adj(m, pad); } - + while ((n = ml_dequeue(&subframes)) != NULL) ieee80211_enqueue_data(ic, n, ni, mcast, ml); @@ -1895,7 +1895,7 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m, ic->ic_updatedtim(ic); } - /* + /* * Reset management timer. If it is non-zero in RUN state, the * driver sent a probe request after a missed beacon event. * This probe response indicates the AP is still serving us diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index 85d795d74..4e0e36eed 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -184,7 +184,7 @@ ieee80211_disable_wep(struct ieee80211com *ic) { struct ieee80211_key *k; int i; - + for (i = 0; i < IEEE80211_WEP_NKID; i++) { k = &ic->ic_nw_keys[i]; if (k->k_cipher != IEEE80211_CIPHER_NONE) @@ -534,7 +534,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) memcmp(join.i_nwid, ic->ic_des_essid, join.i_len) == 0) update_ic = 1; - if (join.i_flags & IEEE80211_JOIN_DEL_ALL && + if (join.i_flags & IEEE80211_JOIN_DEL_ALL && ieee80211_get_ess(ic, ic->ic_des_essid, ic->ic_des_esslen) != NULL) update_ic = 1; diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index c1a06bc7c..01a11bb9a 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -648,7 +648,7 @@ ieee80211_switch_ess(struct ieee80211com *ic) } void -ieee80211_set_ess(struct ieee80211com *ic, struct ieee80211_ess *ess, +ieee80211_set_ess(struct ieee80211com *ic, struct ieee80211_ess *ess, struct ieee80211_node *ni) { memset(ic->ic_des_essid, 0, IEEE80211_NWID_LEN); @@ -967,7 +967,7 @@ ieee80211_create_ibss(struct ieee80211com* ic, struct ieee80211_channel *chan) struct ieee80211_edca_ac_params *ac; int aci; - /* + /* * Configure HT protection. This will be updated later * based on the number of non-HT nodes in the node cache. */ @@ -1199,14 +1199,14 @@ ieee80211_node_tx_stopped(struct ieee80211com *ic, if ((ic->ic_flags & IEEE80211_F_BGSCAN) == 0) return; - /* + /* * Install a callback which will switch us to the new AP once * the de-auth frame has been processed by hardware. * Pass on the existing ni->ni_unref_arg argument. */ ic->ic_bss->ni_unref_cb = ieee80211_node_switch_bss; - /* + /* * All data frames queued to hardware have been flushed and * A-MPDU Tx has been stopped. We are now going to switch APs. * Queue a de-auth frame addressed at our current AP. @@ -1234,7 +1234,7 @@ ieee80211_node_tx_flushed(struct ieee80211com *ic, struct ieee80211_node *ni) /* All data frames queued to hardware have been flushed. */ if (ic->ic_caps & IEEE80211_C_TX_AMPDU) { - /* + /* * Install a callback which will switch us to the * new AP once Tx agg sessions have been stopped, * which involves sending a DELBA frame. @@ -1351,7 +1351,7 @@ ieee80211_node_join_bss(struct ieee80211com *ic, struct ieee80211_node *selbs) timeout_del(&ic->ic_bgscan_timeout); ic->ic_flags &= ~IEEE80211_F_BGSCAN; - /* + /* * After a background scan, we have now switched APs. * Pretend we were just de-authed, which makes * ieee80211_new_state() try to re-auth and thus send @@ -1375,7 +1375,7 @@ struct ieee80211_node * ieee80211_node_choose_bss(struct ieee80211com *ic, int bgscan, struct ieee80211_node **curbs) { - struct ieee80211_node *ni, *nextbs, *selbs = NULL, + struct ieee80211_node *ni, *nextbs, *selbs = NULL, *selbs2 = NULL, *selbs5 = NULL; uint8_t min_5ghz_rssi; @@ -1530,7 +1530,7 @@ ieee80211_end_scan(struct ifnet *ifp) goto notfound; } - /* + /* * After a background scan we might end up choosing the * same AP again. Or the newly selected AP's RSSI level * might be low enough to trigger another background scan. @@ -1562,7 +1562,7 @@ ieee80211_end_scan(struct ifnet *ifp) ieee80211_chan2mode(ic, ni->ni_chan)); return; } - + arg = malloc(sizeof(*arg), M_DEVBUF, M_NOWAIT | M_ZERO); if (arg == NULL) { ic->ic_flags &= ~IEEE80211_F_BGSCAN; @@ -1587,7 +1587,7 @@ ieee80211_end_scan(struct ifnet *ifp) return; } - /* + /* * Install a callback which will switch us to the new AP once * all dispatched frames have been processed by hardware. */ @@ -1990,7 +1990,7 @@ ieee80211_needs_rxnode(struct ieee80211com *ic, return monitor || rc; } -/* +/* * Drivers call this, so increase the reference count before returning * the node. */ @@ -2283,7 +2283,7 @@ ieee80211_clean_nodes(struct ieee80211com *ic, int cache_timeout) } } - /* + /* * During a cache timeout we iterate over all nodes. * Check for node leaks by comparing the actual number of cached * nodes with the ic_nnodes count, which is maintained while adding @@ -2371,7 +2371,7 @@ ieee80211_setup_htcaps(struct ieee80211_node *ni, const uint8_t *data, } #ifndef IEEE80211_STA_ONLY -/* +/* * Handle nodes switching from 11n into legacy modes. */ void @@ -2466,7 +2466,7 @@ ieee80211_setup_vhtop(struct ieee80211_node *ni, const uint8_t *data, } #ifndef IEEE80211_STA_ONLY -/* +/* * Handle nodes switching from 11ac into legacy modes. */ void diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index 6a9fd5f3d..2bc7b4afe 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -420,13 +420,13 @@ struct ieee80211_node { #define IEEE80211_NODE_SA_QUERY 0x0800 /* SA Query in progress */ #define IEEE80211_NODE_SA_QUERY_FAILED 0x1000 /* last SA Query failed */ #define IEEE80211_NODE_RSN_NEW_PTK 0x2000 /* expecting a new PTK */ -#define IEEE80211_NODE_HT_SGI20 0x4000 /* SGI on 20 MHz negotiated */ -#define IEEE80211_NODE_HT_SGI40 0x8000 /* SGI on 40 MHz negotiated */ +#define IEEE80211_NODE_HT_SGI20 0x4000 /* SGI on 20 MHz negotiated */ +#define IEEE80211_NODE_HT_SGI40 0x8000 /* SGI on 40 MHz negotiated */ #define IEEE80211_NODE_VHT 0x10000 /* VHT negotiated */ #define IEEE80211_NODE_HTCAP 0x20000 /* claims to support HT */ #define IEEE80211_NODE_VHTCAP 0x40000 /* claims to support VHT */ -#define IEEE80211_NODE_VHT_SGI80 0x80000 /* SGI on 80 MHz negotiated */ -#define IEEE80211_NODE_VHT_SGI160 0x100000 /* SGI on 160 MHz negotiated */ +#define IEEE80211_NODE_VHT_SGI80 0x80000 /* SGI on 80 MHz negotiated */ +#define IEEE80211_NODE_VHT_SGI160 0x100000 /* SGI on 160 MHz negotiated */ /* If not NULL, this function gets called when ni_refcnt hits zero. */ void (*ni_unref_cb)(struct ieee80211com *, @@ -484,7 +484,7 @@ ieee80211_unref_node(struct ieee80211_node **ni) *ni = NULL; /* guard against use */ } -/* +/* * Check if the peer supports HT. * Require a HT capabilities IE and at least one of the mandatory MCS. * MCS 0-7 are mandatory but some APs have particular MCS disabled. @@ -521,7 +521,7 @@ ieee80211_node_supports_ht_chan40(struct ieee80211_node *ni) (ni->ni_htop0 & IEEE80211_HTOP0_CHW)); } -/* +/* * Check if the peer supports VHT. * Require a VHT capabilities IE and support for VHT MCS with a single * spatial stream. @@ -565,8 +565,8 @@ ieee80211_node_supports_vht_chan80(struct ieee80211_node *ni) cap_chan_width = (ni->ni_vhtcaps & IEEE80211_VHTCAP_CHAN_WIDTH_MASK) >> IEEE80211_VHTCAP_CHAN_WIDTH_SHIFT; - if (cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_80 && - cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_160 && + if (cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_80 && + cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_160 && cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_160_8080) return 0; diff --git a/sys/net80211/ieee80211_pae_input.c b/sys/net80211/ieee80211_pae_input.c index daf550f59..2c1d5ca44 100644 --- a/sys/net80211/ieee80211_pae_input.c +++ b/sys/net80211/ieee80211_pae_input.c @@ -197,7 +197,7 @@ ieee80211_recv_4way_msg1(struct ieee80211com *ic, ic->ic_opmode != IEEE80211_M_IBSS) return; #endif - /* + /* * Message 1 is always expected while RSN is active since some * APs will rekey the PTK by sending Msg1/4 after some time. */ @@ -340,7 +340,7 @@ ieee80211_recv_4way_msg2(struct ieee80211com *ic, } #endif /* IEEE80211_STA_ONLY */ -/* +/* * Check if a group key must be updated with a new GTK from an EAPOL frame. * Manipulated group key handshake messages could trick clients into * reinstalling an already used group key and hence lower or reset the @@ -534,7 +534,7 @@ ieee80211_recv_4way_msg3(struct ieee80211com *ic, if (ieee80211_send_4way_msg4(ic, ni) != 0) return; /* ..authenticator will retry */ - /* + /* * Only install a new pairwise key if we are still expecting a new key, * as indicated by the NODE_RSN_NEW_PTK flag. An adversary could be * sending manipulated retransmissions of message 3 of the 4-way diff --git a/sys/net80211/ieee80211_ra.c b/sys/net80211/ieee80211_ra.c index b820976eb..623eb4e93 100644 --- a/sys/net80211/ieee80211_ra.c +++ b/sys/net80211/ieee80211_ra.c @@ -135,7 +135,7 @@ ieee80211_ra_use_ht_sgi(struct ieee80211_node *ni) return 1; } else if (ni->ni_flags & IEEE80211_NODE_HT_SGI20) return 1; - + return 0; } diff --git a/sys/net80211/ieee80211_ra.h b/sys/net80211/ieee80211_ra.h index 663ce470c..2b6d5b915 100644 --- a/sys/net80211/ieee80211_ra.h +++ b/sys/net80211/ieee80211_ra.h @@ -17,7 +17,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* +/* * Goodput statistics struct. Measures the effective data rate of an MCS. * All uint64_t numbers in this struct use fixed-point arithmetic. */ diff --git a/sys/net80211/ieee80211_ra_vht.c b/sys/net80211/ieee80211_ra_vht.c index 76c9b3bfb..a24498f14 100644 --- a/sys/net80211/ieee80211_ra_vht.c +++ b/sys/net80211/ieee80211_ra_vht.c @@ -140,7 +140,7 @@ ieee80211_ra_vht_use_sgi(struct ieee80211_node *ni) if (ni->ni_flags & IEEE80211_NODE_VHT_SGI80) return 1; } - + return 0; } diff --git a/sys/net80211/ieee80211_ra_vht.h b/sys/net80211/ieee80211_ra_vht.h index 6d463fcf9..881700e52 100644 --- a/sys/net80211/ieee80211_ra_vht.h +++ b/sys/net80211/ieee80211_ra_vht.h @@ -17,7 +17,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* +/* * Goodput statistics struct. Measures the effective data rate of a rate. * All uint64_t numbers in this struct use fixed-point arithmetic. */ diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 2a427b581..3cb1ec929 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -498,8 +498,8 @@ int ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode); enum ieee80211_phymode ieee80211_next_mode(struct ifnet *); enum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *, const struct ieee80211_channel *); -void ieee80211_disable_wep(struct ieee80211com *); -void ieee80211_disable_rsn(struct ieee80211com *); +void ieee80211_disable_wep(struct ieee80211com *); +void ieee80211_disable_rsn(struct ieee80211com *); int ieee80211_add_ess(struct ieee80211com *, struct ieee80211_join *); void ieee80211_del_ess(struct ieee80211com *, char *, int, int); void ieee80211_set_ess(struct ieee80211com *, struct ieee80211_ess *, diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index 210c6191f..0d1fe3d36 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -202,7 +202,7 @@ struct nd_router_advert { /* router advertisement */ #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ -#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ +#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index acb00eb85..b962b8fc8 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -233,7 +233,7 @@ divert_packet(struct mbuf *m, int dir, u_int16_t divert_port) if_put(ifp); } else { /* - * Calculate IP and protocol checksums for outbound packet + * Calculate IP and protocol checksums for outbound packet * diverted to userland. pf rule diverts before cksum offload. */ in_hdr_cksum_out(m, NULL); diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index aaecb6bfa..2da9deea7 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -80,7 +80,7 @@ int gre_send(struct socket *so, struct mbuf *m, struct mbuf *nam, struct mbuf *control) { -#ifdef PIPEX +#ifdef PIPEX struct inpcb *inp = sotoinpcb(so); if (inp->inp_pipex) { diff --git a/sys/netinet/ip_id.c b/sys/netinet/ip_id.c index 3c72c4459..9f66835bd 100644 --- a/sys/netinet/ip_id.c +++ b/sys/netinet/ip_id.c @@ -2,10 +2,10 @@ /* * Copyright (c) 2008 Theo de Raadt, Ryan McBride - * + * * Slightly different algorithm from the one designed by * Matthew Dillon for The DragonFly Project - * + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 66597c5eb..e89b059ab 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -537,7 +537,7 @@ rip_bind(struct socket *so, struct mbuf *nam, struct proc *p) if ((error = in_nam2sin(nam, &addr))) return (error); - + if (!((so->so_options & SO_BINDANY) || addr->sin_addr.s_addr == INADDR_ANY || addr->sin_addr.s_addr == INADDR_BROADCAST || @@ -546,7 +546,7 @@ rip_bind(struct socket *so, struct mbuf *nam, struct proc *p) return (EADDRNOTAVAIL); inp->inp_laddr = addr->sin_addr; - + return (0); } @@ -561,7 +561,7 @@ rip_connect(struct socket *so, struct mbuf *nam) if ((error = in_nam2sin(nam, &addr))) return (error); - + inp->inp_faddr = addr->sin_addr; soisconnected(so); @@ -593,7 +593,7 @@ rip_shutdown(struct socket *so) soassertlocked(so); socantsendmore(so); - + return (0); } diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 7c68c484e..9bdf26614 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -455,10 +455,10 @@ tcp_newtcpcb(struct inpcb *inp, int wait) TCPTV_MIN, TCPTV_REXMTMAX); tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; - + tp->t_pmtud_mtu_sent = 0; tp->t_pmtud_mss_acked = 0; - + #ifdef INET6 /* we disallow IPv4 mapped address completely. */ if ((inp->inp_flags & INP_IPV6) == 0) @@ -628,7 +628,7 @@ tcp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d) if ((unsigned)cmd >= PRC_NCMDS) return; else if (cmd == PRC_QUENCH) { - /* + /* * Don't honor ICMP Source Quench messages meant for * TCP connections. */ @@ -732,7 +732,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v) return; errno = inetctlerrmap[cmd]; if (cmd == PRC_QUENCH) - /* + /* * Don't honor ICMP Source Quench messages meant for * TCP connections. */ @@ -756,7 +756,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v) icp = (struct icmp *)((caddr_t)ip - offsetof(struct icmp, icmp_ip)); - /* + /* * If the ICMP message advertises a Next-Hop MTU * equal or larger than the maximum packet size we have * ever sent, drop the message. @@ -767,7 +767,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v) return; } if (mtu >= tcp_hdrsz(tp) + tp->t_pmtud_mss_acked) { - /* + /* * Calculate new MTU, and create corresponding * route (traditional PMTUD). */ @@ -1076,7 +1076,7 @@ tcp_signature(struct tdb *tdb, int af, struct mbuf *m, struct tcphdr *th, if (len > 0 && m_apply(m, iphlen + th->th_off * sizeof(uint32_t), len, tcp_signature_apply, (caddr_t)&ctx)) - return (-1); + return (-1); MD5Update(&ctx, tdb->tdb_amxkey, tdb->tdb_amxkeylen); MD5Final(sig, &ctx); diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 75d69a12a..b35c05050 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -586,7 +586,7 @@ tcp_listen(struct socket *so) if (inp->inp_lport == 0) if ((error = in_pcbbind(inp, NULL, curproc))) goto out; - + /* * If the in_pcbbind() above is called, the tp->pf * should still be whatever it was before. diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 49b8bc76c..3d7ced8f7 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.121 2022/11/15 18:42:46 claudio Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.122 2023/07/09 19:06:48 bluhm Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -440,10 +440,9 @@ in6_ifdetach(struct ifnet *ifp) sin6.sin6_addr = in6addr_intfacelocal_allnodes; sin6.sin6_addr.s6_addr16[1] = htons(ifp->if_index); rt = rtalloc(sin6tosa(&sin6), 0, ifp->if_rdomain); - if (rt && rt->rt_ifidx == ifp->if_index) { + if (rt && rt->rt_ifidx == ifp->if_index) rtdeletemsg(rt, ifp, ifp->if_rdomain); - rtfree(rt); - } + rtfree(rt); /* remove route to link-local allnodes multicast (ff02::1) */ bzero(&sin6, sizeof(sin6)); @@ -452,10 +451,9 @@ in6_ifdetach(struct ifnet *ifp) sin6.sin6_addr = in6addr_linklocal_allnodes; sin6.sin6_addr.s6_addr16[1] = htons(ifp->if_index); rt = rtalloc(sin6tosa(&sin6), 0, ifp->if_rdomain); - if (rt && rt->rt_ifidx == ifp->if_index) { + if (rt && rt->rt_ifidx == ifp->if_index) rtdeletemsg(rt, ifp, ifp->if_rdomain); - rtfree(rt); - } + rtfree(rt); if (ifp->if_xflags & (IFXF_AUTOCONF6 | IFXF_AUTOCONF6TEMP)) ifp->if_xflags &= ~(IFXF_AUTOCONF6 | IFXF_AUTOCONF6TEMP); diff --git a/sys/netmpls/mpls.h b/sys/netmpls/mpls.h index 702aa90c5..963886120 100644 --- a/sys/netmpls/mpls.h +++ b/sys/netmpls/mpls.h @@ -19,14 +19,14 @@ * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -112,7 +112,7 @@ struct rt_mpls { #define MPLSCTL_DEFTTL 2 #define MPLSCTL_MAPTTL_IP 5 #define MPLSCTL_MAPTTL_IP6 6 -#define MPLSCTL_MAXID 7 +#define MPLSCTL_MAXID 7 #define MPLSCTL_NAMES { \ { NULL, 0 }, \ diff --git a/sys/netmpls/mpls_proto.c b/sys/netmpls/mpls_proto.c index 09c8ffcff..7bef1121d 100644 --- a/sys/netmpls/mpls_proto.c +++ b/sys/netmpls/mpls_proto.c @@ -19,14 +19,14 @@ * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ diff --git a/sys/netmpls/mpls_raw.c b/sys/netmpls/mpls_raw.c index 8aaaf757c..e79b53280 100644 --- a/sys/netmpls/mpls_raw.c +++ b/sys/netmpls/mpls_raw.c @@ -19,14 +19,14 @@ * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ diff --git a/sys/netmpls/mpls_shim.c b/sys/netmpls/mpls_shim.c index 0c6e9ef25..eaf0596f1 100644 --- a/sys/netmpls/mpls_shim.c +++ b/sys/netmpls/mpls_shim.c @@ -19,14 +19,14 @@ * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ diff --git a/sys/nfs/krpc_subr.c b/sys/nfs/krpc_subr.c index eb35b5f6c..1004192c3 100644 --- a/sys/nfs/krpc_subr.c +++ b/sys/nfs/krpc_subr.c @@ -179,7 +179,7 @@ krpc_portmap(struct sockaddr_in *sin, u_int prog, u_int vers, u_int16_t *portp) sin->sin_port = htons(PMAPPORT); error = krpc_call(sin, PMAPPROG, PMAPVERS, PMAPPROC_GETPORT, &m, NULL, -1); - if (error) + if (error) return error; if (m->m_len < sizeof(*rdata)) { diff --git a/sys/nfs/nfs_aiod.c b/sys/nfs/nfs_aiod.c index d40ee305a..3e29b1727 100644 --- a/sys/nfs/nfs_aiod.c +++ b/sys/nfs/nfs_aiod.c @@ -174,7 +174,7 @@ nfs_set_naiod(int howmany) want = howmany - nfs_numaiods; if (want > 0) { - /* Add more. */ + /* Add more. */ want = min(want, NFS_MAXASYNCDAEMON); while (want > 0) { error = kthread_create(nfs_aiod, NULL, NULL, "nfsaio"); diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index b9e1c6f87..158210fb7 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -388,7 +388,7 @@ again: } nfs_del_committed_range(vp, bp); rw_exit_write(&np->n_commitlock); - } else + } else bp->b_flags &= ~B_NEEDCOMMIT; if (ioflag & IO_SYNC) { diff --git a/sys/nfs/nfs_kq.c b/sys/nfs/nfs_kq.c index 999fed0a8..3f5fc4291 100644 --- a/sys/nfs/nfs_kq.c +++ b/sys/nfs/nfs_kq.c @@ -359,7 +359,7 @@ nfs_kqwatch(struct vnode *vp) * Fetch current attributes. It's only needed when the vnode * is not watched yet, but we need to do this without lock * held. This is likely cheap due to attrcache, so do it now. - */ + */ memset(&attr, 0, sizeof(attr)); (void) VOP_GETATTR(vp, &attr, p->p_ucred, p); diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 421c40256..e2a58bc7a 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -2230,10 +2230,10 @@ again: txdr_hyper(dp->d_fileno, tl); else *tl = txdr_unsigned((u_int32_t)dp->d_fileno); - + /* And copy the name */ nfsm_strtombuf(&info.nmi_mb, dp->d_name, nlen); - + /* Finish off the record */ if (info.nmi_v3) { tl = nfsm_build(&info.nmi_mb, 2*NFSX_UNSIGNED); @@ -2405,7 +2405,7 @@ again: * entryplus3 *entries; * bool eof; * } - */ + */ dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED; nfsm_reply(cnt); nfsm_srvpostop_attr(nfsd, getret, &at, &info); @@ -2519,7 +2519,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, int error = 0, rdonly, for_ret = 1, aft_ret = 1, cnt; char *cp2; u_quad_t off; - + info.nmi_mreq = NULL; info.nmi_mrep = nfsd->nd_mrep; info.nmi_md = nfsd->nd_md; @@ -2803,7 +2803,7 @@ nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, int nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq) -{ +{ struct nfsm_info info; int error; diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 5488a5010..525dba33a 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -155,7 +155,7 @@ nfs_init_rtt(struct nfsmount *nmp) /* * Update a mount point's RTT estimator state using data from the * passed-in request. - * + * * Use a gain of 0.125 on the mean and a gain of 0.25 on the deviation. * * NB: Since the timer resolution of NFS_HZ is so course, it can often @@ -244,7 +244,7 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep) nmp->nm_so = NULL; saddr = mtod(nmp->nm_nam, struct sockaddr *); - error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype, + error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype, nmp->nm_soproto); if (error) { nfs_disconnect(nmp); @@ -557,7 +557,7 @@ tryagain: } so = rep->r_nmp->nm_so; if (!so) { - error = nfs_reconnect(rep); + error = nfs_reconnect(rep); if (error) { nfs_sndunlock(&rep->r_nmp->nm_flag); return (error); @@ -771,7 +771,7 @@ nfs_reply(struct nfsreq *myrep) return (error); } m_freem(nam); - + /* * Get the xid and check that it is an rpc reply */ diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index 23fa84bf2..1f2399e95 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -520,7 +520,7 @@ nfsm_reqhead(int hsiz) if (hsiz > MLEN) MCLGET(mb, M_WAIT); mb->m_len = 0; - + /* Finally, return values */ return (mb); } @@ -981,7 +981,7 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp, /* * If v_type == VNON it is a new node, so fill in the v_type, - * n_mtime fields. Check to see if it represents a special + * n_mtime fields. Check to see if it represents a special * device, and if so, check for a possible alias. Once the * correct vnode has been obtained, fill in the rest of the * information. diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index b9eecb043..65bd118e7 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -248,7 +248,7 @@ nfssvc_addsock(struct file *fp, struct mbuf *mynam) else siz = NFS_MAXPACKET; solock(so); - error = soreserve(so, siz, siz); + error = soreserve(so, siz, siz); if (error) { sounlock(so); m_freem(mynam); @@ -592,7 +592,7 @@ nfssvc_iod(void *arg) if (nfs_bufqmax > bcstats.kvaslots / 4) { nfs_bufqmax = bcstats.kvaslots / 4; bufcount = 0; - } + } if (nfs_bufqmax > bcstats.numbufs / 4) { nfs_bufqmax = bcstats.numbufs / 4; bufcount = 0; @@ -616,7 +616,7 @@ nfssvc_iod(void *arg) (void) nfs_doio(bp, NULL); else do { /* - * Look for a delayed write for the same vnode, so I can do + * Look for a delayed write for the same vnode, so I can do * it now. We must grab it before calling nfs_doio() to * avoid any risk of the vnode getting vclean()'d while * we are doing the write rpc. @@ -659,7 +659,7 @@ void nfs_getset_niothreads(int set) { int i, have, start; - + for (have = 0, i = 0; i < NFS_MAXASYNCDAEMON; i++) if (nfs_asyncdaemon[i] != NULL) have++; diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index 384a36766..e45ed66a6 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -178,7 +178,7 @@ nfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p) } copy_statfs_info(sbp, mp); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: vput(vp); crfree(cred); return (error); @@ -245,7 +245,7 @@ nfs_fsinfo(struct nfsmount *nmp, struct vnode *vp, struct ucred *cred, nmp->nm_flag |= NFSMNT_GOTFSINFO; m_freem(info.nmi_mrep); -nfsmout: +nfsmout: return (error); } diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index d61f0a468..b9113639d 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -589,7 +589,7 @@ nfs_getattr(void *v) if (!error) nfsm_loadattr(vp, ap->a_vap); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: return (error); } @@ -732,7 +732,7 @@ nfs_setattrrpc(struct vnode *vp, struct vattr *vap, struct ucred *cred, nfsm_loadattr(vp, NULL); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: return (error); } @@ -970,7 +970,7 @@ dorpc: *vpp = newvp; m_freem(info.nmi_mrep); -nfsmout: +nfsmout: if (error) { /* * We get here only because of errors returned by @@ -1099,7 +1099,7 @@ nfs_readlinkrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) m_freem(info.nmi_mrep); -nfsmout: +nfsmout: return (error); } @@ -1364,7 +1364,7 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, nfsm_wcc_data(dvp, wccflag); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: if (error) { if (newvp) vput(newvp); @@ -1472,7 +1472,7 @@ again: nfsm_wcc_data(dvp, wccflag); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: if (error) { if (newvp) { vput(newvp); @@ -1623,7 +1623,7 @@ nfs_removerpc(struct vnode *dvp, char *name, int namelen, struct ucred *cred, nfsm_wcc_data(dvp, wccflag); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); @@ -1741,7 +1741,7 @@ nfs_renamerpc(struct vnode *fdvp, char *fnameptr, int fnamelen, } m_freem(info.nmi_mrep); -nfsmout: +nfsmout: VTONFS(fdvp)->n_flag |= NMODIFIED; VTONFS(tdvp)->n_flag |= NMODIFIED; if (!fwccflag) @@ -1803,7 +1803,7 @@ nfs_link(void *v) nfsm_wcc_data(dvp, wccflag); } m_freem(info.nmi_mrep); -nfsmout: +nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!attrflag) @@ -1868,7 +1868,7 @@ nfs_symlink(void *v) } m_freem(info.nmi_mrep); -nfsmout: +nfsmout: if (newvp) vput(newvp); pool_put(&namei_pool, cnp->cn_pnbuf); @@ -1931,7 +1931,7 @@ nfs_mkdir(void *v) nfsm_wcc_data(dvp, wccflag); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp)); @@ -1990,7 +1990,7 @@ nfs_rmdir(void *v) nfsm_wcc_data(dvp, wccflag); m_freem(info.nmi_mrep); -nfsmout: +nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) @@ -2012,7 +2012,7 @@ nfsmout: /* - * The readdir logic below has a big design bug. It stores the NFS cookie in + * The readdir logic below has a big design bug. It stores the NFS cookie in * the returned uio->uio_offset but does not store the verifier (it cannot). * Instead, the code stores the verifier in the nfsnode and applies that * verifies to all cookies, no matter what verifier was originally with @@ -2058,7 +2058,7 @@ nfs_readdir(void *v) /* * First, check for hit on the EOF offset cache */ - if (np->n_direofoffset != 0 && + if (np->n_direofoffset != 0 && uio->uio_offset == np->n_direofoffset) { if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_procp) == 0 && timespeccmp(&np->n_mtime, &vattr.va_mtime, ==)) { diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h index 647fda5db..c34c4698d 100644 --- a/sys/nfs/nfsm_subs.h +++ b/sys/nfs/nfsm_subs.h @@ -51,7 +51,7 @@ struct nfsm_info { struct mbuf *nmi_mb; caddr_t nmi_dpos; - int nmi_v3; + int nmi_v3; }; #define nfsm_dissect(a, c, s) { \ diff --git a/sys/ntfs/ntfs_conv.c b/sys/ntfs/ntfs_conv.c index 70d2b103e..dbadbf002 100644 --- a/sys/ntfs/ntfs_conv.c +++ b/sys/ntfs/ntfs_conv.c @@ -144,5 +144,5 @@ ntfs_utf8_wcmp(wchar wc1, wchar wc2) if (wc1 == wc2) return 0; else - return (int) wc1 - (int) wc2; + return (int) wc1 - (int) wc2; } diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index 705e1c0cc..f9187d90f 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -258,9 +258,9 @@ ntfs_loadntnode(struct ntfsmount *ntmp, struct ntnode *ip) struct attr *ap; daddr_t bn; int error,off; - + DPRINTF("ntfs_loadntnode: loading ino: %u\n", ip->i_number); - + KASSERT((ip->i_flag & IN_LOADED) == 0); if (ntmp->ntm_ntnodes >= LOADED_NTNODE_HI) { @@ -279,7 +279,7 @@ ntfs_loadntnode(struct ntfsmount *ntmp, struct ntnode *ip) } mfrp = malloc(ntfs_bntob(ntmp->ntm_bpmftrec), M_TEMP, M_WAITOK); - + if (ip->i_number < NTFS_SYSNODESNUM) { struct buf *bp; @@ -324,7 +324,7 @@ ntfs_loadntnode(struct ntfsmount *ntmp, struct ntnode *ip) ap = (struct attr *) ((caddr_t)mfrp + off); LIST_INIT(&ip->i_valist); - + while (ap->a_hdr.a_type != -1) { error = ntfs_attrtontvattr(ntmp, &vap, ap); if (error) @@ -478,7 +478,7 @@ ntfs_ntput(struct ntnode *ip) } /* - * increment usecount of ntnode + * increment usecount of ntnode */ void ntfs_ntref(struct ntnode *ip) @@ -697,7 +697,7 @@ ntfs_uastrcmp(struct ntfsmount *ntmp, const wchar *ustr, size_t ustrlen, return 1; } -/* +/* * Search fnode in ntnode, if not found allocate and preinitialize. * * ntnode should be locked on entry. @@ -767,7 +767,7 @@ ntfs_frele(struct fnode *fp) } /* - * Lookup attribute name in format: [[:$ATTR_TYPE]:$ATTR_NAME], + * Lookup attribute name in format: [[:$ATTR_TYPE]:$ATTR_NAME], * $ATTR_TYPE is searched in attrdefs read from $AttrDefs. * If $ATTR_TYPE not specified, ATTR_A_DATA assumed. */ @@ -796,7 +796,7 @@ ntfs_ntlookupattr(struct ntfsmount *ntmp, const char *name, int namelen, adp = ntmp->ntm_ad; for (i = 0; i < ntmp->ntm_adnum; i++, adp++){ - if (syslen != adp->ad_namelen || + if (syslen != adp->ad_namelen || strncmp(sys, adp->ad_name, syslen) != 0) continue; @@ -894,7 +894,7 @@ ntfs_ntlookupfile(struct ntfsmount *ntmp, struct vnode *vp, { DDPRINTF("scan: %u, %u\n", iep->ie_number, iep->ie_fnametype); - + /* check the name - the case-insensitive check * has to come first, to break from this for loop * if needed, so we can dive correctly */ @@ -978,9 +978,9 @@ ntfs_ntlookupfile(struct ntfsmount *ntmp, struct vnode *vp, if((nfp->f_fflag & NTFS_FFLAG_DIR) && (nfp->f_attrtype == NTFS_A_DATA) && (nfp->f_attrname == NULL)) - f_type = VDIR; + f_type = VDIR; else - f_type = VREG; + f_type = VREG; nvp->v_type = f_type; @@ -1035,7 +1035,7 @@ ntfs_ntlookupfile(struct ntfsmount *ntmp, struct vnode *vp, "$I30", ntfs_cntob(cn), rdsize, rdbuf, NULL); if (error) goto fail; - + if (cn != 0) { error = ntfs_procfixups(ntmp, NTFS_INDXMAGIC, rdbuf, rdsize); @@ -1299,8 +1299,8 @@ ntfs_nttimetounix(u_int64_t nt) } /* - * Get file sizes from corresponding attribute. - * + * Get file sizes from corresponding attribute. + * * ntnode under fnode should be locked. */ int @@ -1440,7 +1440,7 @@ ntfs_readntvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, if (error != 0) break; } - } else + } else bzero(data, tocopy); data = data + tocopy; } @@ -1454,7 +1454,7 @@ ntfs_readntvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, } } else { DDPRINTF("ntfs_readnvattr_plain: data is in mft record\n"); - if (uio) + if (uio) error = uiomove(vap->va_datap + roff, rsize, uio); else memcpy(rdata, vap->va_datap + roff, rsize); @@ -1667,7 +1667,7 @@ ntfs_procfixups(struct ntfsmount *ntmp, u_int32_t magic, caddr_t buf, } if ((fhp->fh_fnum - 1) * ntmp->ntm_bps != len) { printf("ntfs_procfixups: " \ - "bad fixups number: %d for %ld bytes block\n", + "bad fixups number: %d for %ld bytes block\n", fhp->fh_fnum, (long)len); /* XXX printf kludge */ return (EINVAL); } @@ -1790,7 +1790,7 @@ ntfs_toupper_unuse(struct proc *p) ntfs_toupper_usecount); } #endif - + /* release the lock */ rw_exit_write(&ntfs_toupper_lock); } diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c index d665f5db8..29f1f7e2a 100644 --- a/sys/ntfs/ntfs_vfsops.c +++ b/sys/ntfs/ntfs_vfsops.c @@ -65,7 +65,7 @@ int ntfs_sync(struct mount *, int, int, struct ucred *, int ntfs_unmount(struct mount *, int, struct proc *); int ntfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp); -int ntfs_mountfs(struct vnode *, struct mount *, +int ntfs_mountfs(struct vnode *, struct mount *, struct ntfs_args *, struct proc *); int ntfs_vptofh(struct vnode *, struct fid *); @@ -339,9 +339,9 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode); /* - * We read in some system nodes to do not allow + * We read in some system nodes to do not allow * reclaim them and to have everytime access to them. - */ + */ { int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO }; for (i=0; i<3; i++) { @@ -368,7 +368,7 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, /* * Read and translate to internal format attribute - * definition file. + * definition file. */ { int num,j; @@ -376,7 +376,7 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, /* Open $AttrDef */ error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp ); - if(error) + if(error) goto out1; /* Count valid entries */ @@ -446,7 +446,7 @@ out: vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); (void)VOP_CLOSE(devvp, FREAD, NOCRED, p); VOP_UNLOCK(devvp); - + return (error); } @@ -663,7 +663,7 @@ ntfs_vptofh(struct vnode *vp, struct fid *fhp) int ntfs_vgetex(struct mount *mp, ntfsino_t ino, u_int32_t attrtype, char *attrname, - u_long lkflags, u_long flags, struct vnode **vpp) + u_long lkflags, u_long flags, struct vnode **vpp) { int error; struct ntfsmount *ntmp; @@ -713,9 +713,9 @@ ntfs_vgetex(struct mount *mp, ntfsino_t ino, u_int32_t attrtype, char *attrname, f_type = VNON; fp->f_size = fp->f_allocated = 0; } else { - f_type = VREG; + f_type = VREG; - error = ntfs_filesize(ntmp, fp, + error = ntfs_filesize(ntmp, fp, &fp->f_size, &fp->f_allocated); if (error) { ntfs_ntput(ip); @@ -773,7 +773,7 @@ ntfs_vgetex(struct mount *mp, ntfsino_t ino, u_int32_t attrtype, char *attrname, } int -ntfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +ntfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) { if (ino > (ntfsino_t)-1) panic("ntfs_vget: alien ino_t %llu", (unsigned long long)ino); diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c index d239112e9..18e6ae15e 100644 --- a/sys/ntfs/ntfs_vnops.c +++ b/sys/ntfs/ntfs_vnops.c @@ -219,7 +219,7 @@ ntfs_reclaim(void *v) if ((error = ntfs_ntget(ip)) != 0) return (error); - + /* Purge old data structures associated with the inode. */ cache_purge(vp); @@ -579,7 +579,7 @@ ntfs_lookup(void *v) DPRINTF("ntfs_lookup: parentdir: %u\n", vap->va_a_name->n_pnumber); error = VFS_VGET(ntmp->ntm_mountp, - vap->va_a_name->n_pnumber,ap->a_vpp); + vap->va_a_name->n_pnumber,ap->a_vpp); ntfs_ntvattrrele(vap); if (error) { if (vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY) == 0) diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 8e8fb131f..b0c76c2e7 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.260 2023/07/07 14:17:34 yasuoka Exp $ */ +/* $OpenBSD: mbuf.h,v 1.261 2023/07/16 03:01:31 yasuoka Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -363,6 +363,12 @@ u_int mextfree_register(void (*)(caddr_t, u_int, void *)); /* length to m_copy to copy all */ #define M_COPYALL 1000000000 +#define MBSTAT_TYPES MT_NTYPES +#define MBSTAT_DROPS (MBSTAT_TYPES + 0) +#define MBSTAT_WAIT (MBSTAT_TYPES + 1) +#define MBSTAT_DRAIN (MBSTAT_TYPES + 2) +#define MBSTAT_COUNT (MBSTAT_TYPES + 3) + /* * Mbuf statistics. * For statistics related to mbuf and cluster allocations, see also the @@ -372,15 +378,10 @@ struct mbstat { u_long m_drops; /* times failed to find space */ u_long m_wait; /* times waited for space */ u_long m_drain; /* times drained protocols for space */ - u_long m_mtypes[256]; /* type specific mbuf allocations */ + u_long m_mtypes[MBSTAT_COUNT]; + /* type specific mbuf allocations */ }; -#define MBSTAT_TYPES MT_NTYPES -#define MBSTAT_DROPS (MBSTAT_TYPES + 0) -#define MBSTAT_WAIT (MBSTAT_TYPES + 1) -#define MBSTAT_DRAIN (MBSTAT_TYPES + 2) -#define MBSTAT_COUNT (MBSTAT_TYPES + 3) - #include struct mbuf_list { diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 6869483e1..7bad09435 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.343 2023/07/04 11:14:00 jsg Exp $ */ +/* $OpenBSD: proc.h,v 1.346 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -281,6 +281,7 @@ struct process { #define PS_EXECPLEDGE 0x00400000 /* Has exec pledges */ #define PS_ORPHAN 0x00800000 /* Process is on an orphan list */ #define PS_CHROOT 0x01000000 /* Process is chrooted */ +#define PS_NOBTCFI 0x02000000 /* No Branch Target CFI */ #define PS_BITS \ ("\20" "\01CONTROLT" "\02EXEC" "\03INEXEC" "\04EXITING" "\05SUGID" \ @@ -288,7 +289,7 @@ struct process { "\013WAITED" "\014COREDUMP" "\015SINGLEEXIT" "\016SINGLEUNWIND" \ "\017NOZOMBIE" "\020STOPPED" "\021SYSTEM" "\022EMBRYO" "\023ZOMBIE" \ "\024NOBROADCASTKILL" "\025PLEDGE" "\026WXNEEDED" "\027EXECPLEDGE" \ - "\030ORPHAN" "\031CHROOT") + "\030ORPHAN" "\031CHROOT" "\032NOBTCFI") struct kcov_dev; @@ -413,6 +414,7 @@ struct proc { #define P_ALRMPEND 0x00000004 /* SIGVTALRM needs to be posted */ #define P_SIGSUSPEND 0x00000008 /* Need to restore before-suspend mask*/ #define P_CANTSLEEP 0x00000010 /* insomniac thread */ +#define P_WSLEEP 0x00000020 /* Working on going to sleep. */ #define P_SINTR 0x00000080 /* Sleep is interruptible. */ #define P_SYSTEM 0x00000200 /* No sigs, stats or swapping. */ #define P_TIMEOUT 0x00000400 /* Timing out during sleep. */ @@ -427,7 +429,7 @@ struct proc { #define P_BITS \ ("\20" "\01INKTR" "\02PROFPEND" "\03ALRMPEND" "\04SIGSUSPEND" \ - "\05CANTSLEEP" "\010SINTR" "\012SYSTEM" "\013TIMEOUT" \ + "\05CANTSLEEP" "\06WSLEEP" "\010SINTR" "\012SYSTEM" "\013TIMEOUT" \ "\016WEXIT" "\020OWEUPC" "\024SUSPSINGLE" "\027XX" \ "\030CONTINUED" "\033THREAD" "\034SUSPSIG" "\035SOFTDEP" "\037CPUPEG") @@ -583,10 +585,6 @@ void child_return(void *); int proc_cansugid(struct proc *); -struct sleep_state { - int sls_s; -}; - struct cond { unsigned int c_wait; /* [a] initialized and waiting */ }; diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 3dbbb8cec..0b84800e3 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -4,7 +4,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from; OpenBSD: syscalls.master,v 1.248 2023/05/18 10:23:19 mvs Exp + * created from; OpenBSD: syscalls.master,v 1.248 2023/05/18 10:23:19 mvs Exp */ /* syscall: "syscall" ret: "int" args: "int" "..." */ diff --git a/sys/sys/syscallargs.h b/sys/sys/syscallargs.h index 63519efa3..e4cc02016 100644 --- a/sys/sys/syscallargs.h +++ b/sys/sys/syscallargs.h @@ -4,7 +4,7 @@ * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from; OpenBSD: syscalls.master,v 1.248 2023/05/18 10:23:19 mvs Exp + * created from; OpenBSD: syscalls.master,v 1.248 2023/05/18 10:23:19 mvs Exp */ #ifdef syscallarg diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 29115bc03..8511338ef 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.162 2023/06/28 08:23:25 claudio Exp $ */ +/* $OpenBSD: systm.h,v 1.163 2023/07/14 07:07:08 claudio Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -249,10 +249,8 @@ void setstatclockrate(int); void start_periodic_resettodr(void); void stop_periodic_resettodr(void); -struct sleep_state; -void sleep_setup(struct sleep_state *, const volatile void *, int, - const char *); -int sleep_finish(struct sleep_state *, int, int, int); +void sleep_setup(const volatile void *, int, const char *); +int sleep_finish(int, int); void sleep_queue_init(void); struct cond; diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index ff6d46997..ecdad0566 100644 --- a/sys/ufs/mfs/mfs_vfsops.c +++ b/sys/ufs/mfs/mfs_vfsops.c @@ -110,7 +110,7 @@ mfs_mount(struct mount *mp, const char *path, void *data, fs->fs_ronly = 0; #ifdef EXPORTMFS if (args && args->fspec == NULL) - return (vfs_export(mp, &ump->um_export, + return (vfs_export(mp, &ump->um_export, &args->export_info)); #endif return (0); diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 366615881..d09b52f73 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -130,10 +130,10 @@ struct inode { }; struct inode_vtbl { - int (* iv_truncate)(struct inode *, off_t, int, + int (* iv_truncate)(struct inode *, off_t, int, struct ucred *); int (* iv_update)(struct inode *, int waitfor); - int (* iv_inode_alloc)(struct inode *, mode_t mode, + int (* iv_inode_alloc)(struct inode *, mode_t mode, struct ucred *, struct vnode **); int (* iv_inode_free)(struct inode *, ufsino_t ino, mode_t mode); int (* iv_buf_alloc)(struct inode *, off_t, int, struct ucred *, @@ -157,7 +157,7 @@ struct inode_vtbl { #define UFS_BUF_ALLOC(ip, startoffset, size, cred, flags, bpp) \ ((ip)->i_vtbl->iv_buf_alloc)((ip), (startoffset), (size), (cred), \ (flags), (bpp)) - + #define UFS_BUFATOFF(ip, offset, res, bpp) \ ((ip)->i_vtbl->iv_bufatoff)((ip), (offset), (res), (bpp)) diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index b094e5b9d..09b578fb3 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -143,7 +143,7 @@ ufs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, struct indir *ap, devvp = VFSTOUFS(vp->v_mount)->um_devvp; for (bp = NULL, ++xap; --num; ++xap) { - /* + /* * Exit the loop if there is no disk address assigned yet and * the indirect block isn't in the cache, or if we were * looking for an indirect block and we've found it. @@ -250,7 +250,7 @@ ufs_getlbns(struct vnode *vp, daddr_t bn, struct indir *ap, int *nump) if (bn < NDADDR) return (0); - /* + /* * Determine the number of levels of indirection. After this loop * is done, blockcnt indicates the number of data blocks possible * at the given level of indirection, and NIADDR - i is the number @@ -270,7 +270,7 @@ ufs_getlbns(struct vnode *vp, daddr_t bn, struct indir *ap, int *nump) else metalbn = -(-realbn - bn + NIADDR - i); - /* + /* * At each iteration, off is the offset into the bap array which is * an array of disk addresses at the current level of indirection. * The logical block number and the offset in that block are stored diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index 15ae5b94a..750dcd07c 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -133,7 +133,7 @@ void ufs_itimes(struct vnode *); int ufs_makeinode(int, struct vnode *, struct vnode **, struct componentname *); - + /* * Soft dependency function prototypes. */ diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 3cf88f301..3e488a753 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -684,7 +684,7 @@ ufs_makedirentry(struct inode *ip, struct componentname *cnp, } else newdirp->d_type = IFTODT(DIP(ip, mode)); } - + /* * Write a directory entry after a call to namei, using the parameters * that it left in nameidata. The argument dirp is the new directory @@ -814,7 +814,7 @@ ufs_direnter(struct vnode *dvp, struct vnode *tvp, struct direct *dirp, /* * Get the block containing the space for the new directory entry. */ - if ((error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, &dirbuf, &bp)) + if ((error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, &dirbuf, &bp)) != 0) { if (DOINGSOFTDEP(dvp) && newdirbp != NULL) bdwrite(newdirbp); @@ -862,7 +862,7 @@ ufs_direnter(struct vnode *dvp, struct vnode *tvp, struct direct *dirp, #endif if (DOINGSOFTDEP(dvp)) softdep_change_directoryentry_offset(dp, dirbuf, - (caddr_t)nep, (caddr_t)ep, dsize); + (caddr_t)nep, (caddr_t)ep, dsize); else memmove(ep, nep, dsize); } diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index 118fc0681..0dd2b9c4e 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -179,7 +179,7 @@ getinoquota(struct inode *ip) /* * Update disk usage, and take corrective action. */ -int +int ufs_quota_alloc_blocks2(struct inode *ip, daddr_t change, struct ucred *cred, enum ufs_quota_flags flags) { @@ -194,10 +194,10 @@ ufs_quota_alloc_blocks2(struct inode *ip, daddr_t change, if (change == 0) return (0); - if ((flags & UFS_QUOTA_FORCE) == 0 && + if ((flags & UFS_QUOTA_FORCE) == 0 && (cred != NOCRED && cred->cr_uid != 0)) { for (i = 0; i < MAXQUOTAS; i++) { - if (flags & (1 << i)) + if (flags & (1 << i)) continue; if ((dq = ip->i_dquot[i]) == NODQUOT) continue; @@ -228,11 +228,11 @@ ufs_quota_free_blocks2(struct inode *ip, daddr_t change, int i; #ifdef DIAGNOSTIC - if (!VOP_ISLOCKED(ITOV(ip))) + if (!VOP_ISLOCKED(ITOV(ip))) panic ("ufs_quota_free_blocks2: vnode is not locked"); #endif - if (change == 0) + if (change == 0) return (0); for (i = 0; i < MAXQUOTAS; i++) { @@ -322,7 +322,7 @@ ufs_quota_alloc_inode2(struct inode *ip, struct ucred *cred, if ((flags & UFS_QUOTA_FORCE) == 0 && cred->cr_uid != 0) { for (i = 0; i < MAXQUOTAS; i++) { - if (flags & (1 << i)) + if (flags & (1 << i)) continue; if ((dq = ip->i_dquot[i]) == NODQUOT) continue; @@ -331,7 +331,7 @@ ufs_quota_alloc_inode2(struct inode *ip, struct ucred *cred, } } for (i = 0; i < MAXQUOTAS; i++) { - if (flags & (1 << i)) + if (flags & (1 << i)) continue; if ((dq = ip->i_dquot[i]) == NODQUOT) continue; @@ -353,12 +353,12 @@ ufs_quota_free_inode2(struct inode *ip, struct ucred *cred, int i; #ifdef DIAGNOSTIC - if (!VOP_ISLOCKED(ITOV(ip))) + if (!VOP_ISLOCKED(ITOV(ip))) panic ("ufs_quota_free_blocks2: vnode is not locked"); #endif for (i = 0; i < MAXQUOTAS; i++) { - if (flags & (1 << i)) + if (flags & (1 << i)) continue; if ((dq = ip->i_dquot[i]) == NODQUOT) continue; @@ -437,9 +437,9 @@ chkdquot(struct inode *ip) int i; struct vnode *vp = ITOV(ip); - if (!VOP_ISLOCKED(vp)) + if (!VOP_ISLOCKED(vp)) panic ("chkdquot: vnode is not locked"); - + for (i = 0; i < MAXQUOTAS; i++) { if (ump->um_quotas[i] == NULLVP || (ump->um_qflags[i] & (QTF_OPENING|QTF_CLOSING))) @@ -457,7 +457,7 @@ chkdquot(struct inode *ip) */ int -quotaon_vnode(struct vnode *vp, void *arg) +quotaon_vnode(struct vnode *vp, void *arg) { int error; @@ -470,7 +470,7 @@ quotaon_vnode(struct vnode *vp, void *arg) error = getinoquota(VTOI(vp)); vput(vp); - + return (error); } @@ -555,7 +555,7 @@ struct quotaoff_arg { }; int -quotaoff_vnode(struct vnode *vp, void *arg) +quotaoff_vnode(struct vnode *vp, void *arg) { struct quotaoff_arg *qa = (struct quotaoff_arg *)arg; struct inode *ip; @@ -584,7 +584,7 @@ quotaoff(struct proc *p, struct mount *mp, int type) struct ufsmount *ump = VFSTOUFS(mp); struct quotaoff_arg qa; int error; - + #ifdef DIAGNOSTIC if (!vfs_isbusy(mp)) panic ("quotaoff: mount point not busy"); @@ -757,7 +757,7 @@ qsync_vnode(struct vnode *vp, void *arg) { int i; struct dquot *dq; - + if (vp->v_type == VNON) return (0); @@ -1062,7 +1062,7 @@ ufs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg, if (vfs_busy(mp, VB_READ|VB_NOWAIT)) return (0); - + switch (cmd) { diff --git a/sys/ufs/ufs/ufs_quota_stub.c b/sys/ufs/ufs/ufs_quota_stub.c index ed7f8fefd..b904810e1 100644 --- a/sys/ufs/ufs/ufs_quota_stub.c +++ b/sys/ufs/ufs/ufs_quota_stub.c @@ -21,13 +21,13 @@ getinoquota(struct inode *ip) { } int -ufs_quota_alloc_blocks2(struct inode *ip, daddr_t change, +ufs_quota_alloc_blocks2(struct inode *ip, daddr_t change, struct ucred *cred, enum ufs_quota_flags flags) { return (0); } int -ufs_quota_free_blocks2(struct inode *ip, daddr_t change, +ufs_quota_free_blocks2(struct inode *ip, daddr_t change, struct ucred *cred, enum ufs_quota_flags flags) { return (0); } diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 3c06100c4..d361d6db2 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -84,7 +84,7 @@ ufs_root(struct mount *mp, struct vnode **vpp) */ int ufs_check_export(struct mount *mp, struct mbuf *nam, int *exflagsp, - struct ucred **credanonp) + struct ucred **credanonp) { struct netcred *np; struct ufsmount *ump = VFSTOUFS(mp); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index a76d8940c..edd637fc5 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -417,7 +417,7 @@ ufs_setattr(void *v) if (cred->cr_uid != DIP(ip, uid) && !vnoperm(vp) && (error = suser_ucred(cred)) && - ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || + ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || (error = VOP_ACCESS(vp, VWRITE, cred, ap->a_p)))) return (error); if (vap->va_mtime.tv_nsec != VNOVAL) @@ -514,7 +514,7 @@ ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred) if (ouid == uid) quota_flags |= UFS_QUOTA_NOUID; - + if (ogid == gid) quota_flags |= UFS_QUOTA_NOGID; @@ -530,14 +530,14 @@ ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred) if ((error = getinoquota(ip)) != 0) goto error; - if ((error = ufs_quota_alloc_blocks2(ip, change, cred, - quota_flags)) != 0) + if ((error = ufs_quota_alloc_blocks2(ip, change, cred, + quota_flags)) != 0) goto error; if ((error = ufs_quota_alloc_inode2(ip, cred , quota_flags)) != 0) { - (void)ufs_quota_free_blocks2(ip, change, cred, - quota_flags); + (void)ufs_quota_free_blocks2(ip, change, cred, + quota_flags); goto error; } @@ -561,7 +561,7 @@ error: DIP_ASSIGN(ip, uid, ouid); if (getinoquota(ip) == 0) { - (void) ufs_quota_alloc_blocks2(ip, change, cred, + (void) ufs_quota_alloc_blocks2(ip, change, cred, quota_flags | UFS_QUOTA_FORCE); (void) ufs_quota_alloc_inode2(ip, cred, quota_flags | UFS_QUOTA_FORCE); @@ -863,7 +863,7 @@ abortit: * directory hierarchy above the target, as this would * orphan everything below the source directory. Also * the user must have write permission in the source so - * as to be able to change "..". We must repeat the call + * as to be able to change "..". We must repeat the call * to namei, as the parent directory is unlocked by the * call to checkpath(). */ @@ -899,7 +899,7 @@ abortit: } /* * 2) If target doesn't exist, link the target - * to the source and unlink the source. + * to the source and unlink the source. * Otherwise, rewrite the target directory * entry to reference the source inode and * expunge the original entry's existence. @@ -922,7 +922,7 @@ abortit: dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tdvp)) softdep_change_linkcnt(dp, 0); - if ((error = UFS_UPDATE(dp, !DOINGSOFTDEP(tdvp))) + if ((error = UFS_UPDATE(dp, !DOINGSOFTDEP(tdvp))) != 0) { dp->i_effnlink--; DIP_ADD(dp, nlink, -1); @@ -987,7 +987,7 @@ abortit: error = EISDIR; goto bad; } - + if ((error = ufs_dirrewrite(dp, xp, ip->i_number, IFTODT(DIP(ip, mode)), (doingdirectory && newparent) ? newparent : doingdirectory)) != 0) @@ -1062,7 +1062,7 @@ abortit: * changed while the new name has been entered. If the source is * a file then the entry may have been unlinked or renamed. In * either case there is no further work to be done. If the source - * is a directory then it cannot have been rmdir'ed; the IN_RENAME + * is a directory then it cannot have been rmdir'ed; the IN_RENAME * flag ensures that it cannot be moved by another rename or removed * by a rmdir. */ @@ -1173,7 +1173,7 @@ ufs_mkdir(void *v) /* * Bump link count in parent directory to reflect work done below. - * Should be done before reference is create so cleanup is + * Should be done before reference is create so cleanup is * possible if we crash. */ dp->i_effnlink++; @@ -1184,7 +1184,7 @@ ufs_mkdir(void *v) if ((error = UFS_UPDATE(dp, !DOINGSOFTDEP(dvp))) != 0) goto bad; - /* + /* * Initialize directory with "." and ".." from static template. */ if (dp->i_ump->um_maxsymlinklen > 0) @@ -1236,7 +1236,7 @@ ufs_mkdir(void *v) goto bad; ufs_makedirentry(ip, cnp, &newdir); error = ufs_direnter(dvp, tvp, &newdir, cnp, bp); - + bad: if (error == 0) { VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK); @@ -1391,7 +1391,7 @@ ufs_symlink(void *v) /* * Vnode op for reading directories. - * + * * This routine converts the on-disk struct direct entries to the * struct dirent entries expected by userland and the rest of the kernel. */ @@ -1941,7 +1941,7 @@ filt_ufsread(struct knote *kn, long hint) struct inode *ip = VTOI(vp); /* - * filesystem is gone, so set the EOF flag and schedule + * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. */ if (hint == NOTE_REVOKE) { @@ -1970,7 +1970,7 @@ int filt_ufswrite(struct knote *kn, long hint) { /* - * filesystem is gone, so set the EOF flag and schedule + * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. */ if (hint == NOTE_REVOKE) { diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index 63dc85340..440543f47 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -67,7 +67,7 @@ static char amap_small_pool_names[UVM_AMAP_CHUNK][9]; static struct vm_amap *amap_alloc1(int, int, int); static inline void amap_list_insert(struct vm_amap *); -static inline void amap_list_remove(struct vm_amap *); +static inline void amap_list_remove(struct vm_amap *); struct vm_amap_chunk *amap_chunk_get(struct vm_amap *, int, int, int); void amap_chunk_free(struct vm_amap *, struct vm_amap_chunk *); @@ -693,7 +693,7 @@ amap_copy(struct vm_map *map, struct vm_map_entry *entry, int waitf, srcamap->am_flags &= ~AMAP_SHARED; /* clear shared flag */ #ifdef UVM_AMAP_PPREF if (srcamap->am_ppref && srcamap->am_ppref != PPREF_NONE) { - amap_pp_adjref(srcamap, entry->aref.ar_pageoff, + amap_pp_adjref(srcamap, entry->aref.ar_pageoff, (entry->end - entry->start) >> PAGE_SHIFT, -1); } #endif diff --git a/sys/uvm/uvm_amap.h b/sys/uvm/uvm_amap.h index fc0c4df0b..7f45a8e18 100644 --- a/sys/uvm/uvm_amap.h +++ b/sys/uvm/uvm_amap.h @@ -53,13 +53,13 @@ /* * forward definition of vm_amap structure. only amap * implementation-specific code should directly access the fields of - * this structure. + * this structure. */ struct vm_amap; /* - * prototypes for the amap interface + * prototypes for the amap interface */ /* ensure amap can store anon */ @@ -192,7 +192,7 @@ struct vm_amap { /* * defines for handling of large sparce amaps: - * + * * one of the problems of array-based amaps is that if you allocate a * large sparcely-used area of virtual memory you end up allocating * large arrays that, for the most part, don't get used. this is a @@ -205,15 +205,15 @@ struct vm_amap { * it makes sense for it to live in an amap, but if we allocated an * amap for the entire stack range we could end up wasting a large * amount of malloc'd KVM. - * - * for example, on the i386 at boot time we allocate two amaps for the stack - * of /sbin/init: + * + * for example, on the i386 at boot time we allocate two amaps for the stack + * of /sbin/init: * 1. a 7680 slot amap at protection PROT_NONE (reserve space for stack) * 2. a 512 slot amap at protection PROT_READ|PROT_WRITE (top of stack) * - * most of the array allocated for the amaps for this is never used. + * most of the array allocated for the amaps for this is never used. * the amap interface provides a way for us to avoid this problem by - * allowing amap_copy() to break larger amaps up into smaller sized + * allowing amap_copy() to break larger amaps up into smaller sized * chunks (controlled by the "canchunk" option). we use this feature * to reduce our memory usage with the BSD stack management. if we * are asked to create an amap with more than UVM_AMAP_LARGE slots in it, diff --git a/sys/uvm/uvm_anon.h b/sys/uvm/uvm_anon.h index 7db12a822..d68965d22 100644 --- a/sys/uvm/uvm_anon.h +++ b/sys/uvm/uvm_anon.h @@ -66,7 +66,7 @@ struct vm_anon { */ /* - * processes reference anonymous virtual memory maps with an anonymous + * processes reference anonymous virtual memory maps with an anonymous * reference structure: * Note that the offset field indicates which part of the amap we are * referencing. diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c index 490c94d67..6d8dc76c0 100644 --- a/sys/uvm/uvm_aobj.c +++ b/sys/uvm/uvm_aobj.c @@ -129,7 +129,7 @@ struct uvm_aobj { * Either an array or hashtable (array of bucket heads) of * offset -> swapslot mappings for the aobj. */ -#define u_swslots u_swap.slot_array +#define u_swslots u_swap.slot_array #define u_swhash u_swap.slot_hash union swslots { int *slot_array; @@ -622,7 +622,7 @@ uao_grow_convert(struct uvm_object *uobj, int pages) /* Set these now, so we can use uao_find_swhash_elt(). */ old_swslots = aobj->u_swslots; - aobj->u_swhash = new_swhash; + aobj->u_swhash = new_swhash; aobj->u_swhashmask = new_hashmask; for (i = 0; i < aobj->u_pages; i++) { @@ -1050,7 +1050,7 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, if (lcv == centeridx || (flags & PGO_ALLPAGES) != 0) /* need to do a wait or I/O! */ - done = FALSE; + done = FALSE; continue; } @@ -1071,7 +1071,7 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, *npagesp = gotpages; if (done) /* bingo! */ - return VM_PAGER_OK; + return VM_PAGER_OK; else /* EEK! Need to unlock and I/O */ return VM_PAGER_UNLOCK; @@ -1135,7 +1135,7 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, */ atomic_setbits_int(&ptmp->pg_flags, PQ_AOBJ); - /* + /* * got new page ready for I/O. break pps while * loop. pps[lcv] is still NULL. */ @@ -1167,7 +1167,7 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, continue; /* next lcv */ /* - * we have a "fake/busy/clean" page that we just allocated. + * we have a "fake/busy/clean" page that we just allocated. * do the needed "i/o", either reading from swap or zeroing. */ swslot = uao_find_swslot(uobj, pageidx); @@ -1255,7 +1255,7 @@ uao_dropswap(struct uvm_object *uobj, int pageidx) /* * page in every page in every aobj that is paged-out to a range of swslots. - * + * * => aobj must be locked and is returned locked. * => returns TRUE if pagein was aborted due to lack of memory. */ diff --git a/sys/uvm/uvm_device.c b/sys/uvm/uvm_device.c index 74d9490b3..818cf70e5 100644 --- a/sys/uvm/uvm_device.c +++ b/sys/uvm/uvm_device.c @@ -121,7 +121,7 @@ udv_attach(dev_t device, vm_prot_t accessprot, voff_t off, vsize_t size) /* * Check that the specified range of the device allows the * desired protection. - * + * * XXX clobbers off and size, but nothing else here needs them. */ while (size != 0) { @@ -219,7 +219,7 @@ udv_attach(dev_t device, vm_prot_t accessprot, voff_t off, vsize_t size) } /*NOTREACHED*/ } - + /* * udv_reference * @@ -387,7 +387,7 @@ udv_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, vm_page_t *pps, int npages, uobj); /* sync what we have so far */ - pmap_update(ufi->orig_map->pmap); + pmap_update(ufi->orig_map->pmap); uvm_wait("udv_fault"); return (VM_PAGER_REFAULT); } diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index a6fc5f041..42e5ed806 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -287,7 +287,7 @@ int uvm_vslock_device(struct proc *, void *, size_t, void uvm_vsunlock_device(struct proc *, void *, size_t, void *); void uvm_pause(void); -void uvm_init(void); +void uvm_init(void); void uvm_init_percpu(void); int uvm_io(vm_map_t, struct uio *, int); @@ -396,12 +396,12 @@ void km_free(void *, size_t, const struct kmem_va_mode *, int uvm_map(vm_map_t, vaddr_t *, vsize_t, struct uvm_object *, voff_t, vsize_t, unsigned int); int uvm_mapanon(vm_map_t, vaddr_t *, vsize_t, vsize_t, unsigned int); -int uvm_map_pageable(vm_map_t, vaddr_t, +int uvm_map_pageable(vm_map_t, vaddr_t, vaddr_t, boolean_t, int); int uvm_map_pageable_all(vm_map_t, int, vsize_t); boolean_t uvm_map_checkprot(vm_map_t, vaddr_t, vaddr_t, vm_prot_t); -int uvm_map_protect(vm_map_t, vaddr_t, +int uvm_map_protect(vm_map_t, vaddr_t, vaddr_t, vm_prot_t, int etype, boolean_t, boolean_t); struct vmspace *uvmspace_alloc(vaddr_t, vaddr_t, boolean_t, boolean_t); @@ -415,13 +415,13 @@ struct vmspace *uvmspace_share(struct process *); int uvm_share(vm_map_t, vaddr_t, vm_prot_t, vm_map_t, vaddr_t, vsize_t); void uvm_meter(void); -int uvm_sysctl(int *, u_int, void *, size_t *, +int uvm_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *); struct vm_page *uvm_pagealloc(struct uvm_object *, voff_t, struct vm_anon *, int); int uvm_pagealloc_multi(struct uvm_object *, voff_t, vsize_t, int); -void uvm_pagerealloc(struct vm_page *, +void uvm_pagerealloc(struct vm_page *, struct uvm_object *, voff_t); int uvm_pagerealloc_multi(struct uvm_object *, voff_t, vsize_t, int, struct uvm_constraint_range *); diff --git a/sys/uvm/uvm_glue.c b/sys/uvm/uvm_glue.c index 9c45bfdb7..fb7fe6b27 100644 --- a/sys/uvm/uvm_glue.c +++ b/sys/uvm/uvm_glue.c @@ -1,9 +1,9 @@ /* $OpenBSD: uvm_glue.c,v 1.84 2022/09/10 20:35:29 miod Exp $ */ /* $NetBSD: uvm_glue.c,v 1.44 2001/02/06 19:54:44 eeh Exp $ */ -/* +/* * Copyright (c) 1997 Charles D. Cranor and Washington University. - * Copyright (c) 1991, 1993, The Regents of the University of California. + * Copyright (c) 1991, 1993, The Regents of the University of California. * * All rights reserved. * @@ -40,17 +40,17 @@ * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. - * + * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU @@ -349,7 +349,7 @@ uvm_swapout_threads(void) struct process *outpr; int outpri; int didswap = 0; - extern int maxslp; + extern int maxslp; /* XXXCDC: should move off to uvmexp. or uvm., also in uvm_meter */ #ifdef DEBUG @@ -427,7 +427,7 @@ uvm_atopg(vaddr_t kva) struct vm_page *pg; paddr_t pa; boolean_t rv; - + rv = pmap_extract(pmap_kernel(), kva, &pa); KASSERT(rv); pg = PHYS_TO_VM_PAGE(pa); diff --git a/sys/uvm/uvm_km.c b/sys/uvm/uvm_km.c index d5dcc8784..6c5e48da0 100644 --- a/sys/uvm/uvm_km.c +++ b/sys/uvm/uvm_km.c @@ -1,9 +1,9 @@ /* $OpenBSD: uvm_km.c,v 1.151 2022/08/01 14:15:46 mpi Exp $ */ /* $NetBSD: uvm_km.c,v 1.42 2001/01/14 02:10:01 thorpej Exp $ */ -/* +/* * Copyright (c) 1997 Charles D. Cranor and Washington University. - * Copyright (c) 1991, 1993, The Regents of the University of California. + * Copyright (c) 1991, 1993, The Regents of the University of California. * * All rights reserved. * @@ -40,17 +40,17 @@ * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. - * + * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU @@ -73,11 +73,11 @@ * starts at a machine-dependent address and is VM_KERNEL_SPACE_SIZE bytes * large. * - * the kernel_map has several "submaps." submaps can only appear in + * the kernel_map has several "submaps." submaps can only appear in * the kernel_map (user processes can't use them). submaps "take over" * the management of a sub-range of the kernel's address space. submaps * are typically allocated at boot time and are never released. kernel - * virtual address space that is mapped by a submap is locked by the + * virtual address space that is mapped by a submap is locked by the * submap's lock -- not the kernel_map's lock. * * thus, the useful feature of submaps is that they allow us to break @@ -97,7 +97,7 @@ * the kernel allocates its private memory out of special uvm_objects whose * reference count is set to UVM_OBJ_KERN (thus indicating that the objects * are "special" and never die). all kernel objects should be thought of - * as large, fixed-sized, sparsely populated uvm_objects. each kernel + * as large, fixed-sized, sparsely populated uvm_objects. each kernel * object is equal to the size of kernel virtual address space (i.e. * VM_KERNEL_SPACE_SIZE). * @@ -107,8 +107,8 @@ * * note that just because a kernel object spans the entire kernel virtual * address space doesn't mean that it has to be mapped into the entire space. - * large chunks of a kernel object's space go unused either because - * that area of kernel VM is unmapped, or there is some other type of + * large chunks of a kernel object's space go unused either because + * that area of kernel VM is unmapped, or there is some other type of * object mapped into that range (e.g. a vnode). for submap's kernel * objects, the only part of the object that can ever be populated is the * offsets that are managed by the submap. @@ -120,7 +120,7 @@ * uvm_km_alloc(kernel_map, PAGE_SIZE) [allocate 1 wired down page in the * kernel map]. if uvm_km_alloc returns virtual address 0xf8235000, * then that means that the page at offset 0x235000 in kernel_object is - * mapped at 0xf8235000. + * mapped at 0xf8235000. * * kernel objects have one other special property: when the kernel virtual * memory mapping them is unmapped, the backing memory in the object is @@ -165,7 +165,7 @@ uvm_km_init(vaddr_t base, vaddr_t start, vaddr_t end) uvm.kernel_object = uao_create(VM_KERNEL_SPACE_SIZE, UAO_FLAG_KERNOBJ); /* - * init the map and reserve already allocated kernel space + * init the map and reserve already allocated kernel space * before installing. */ @@ -181,7 +181,7 @@ uvm_km_init(vaddr_t base, vaddr_t start, vaddr_t end) UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE, MAP_INHERIT_NONE, MADV_RANDOM, UVM_FLAG_FIXED)) != 0) panic("uvm_km_init: could not reserve space for kernel"); - + kernel_map = &kernel_map_store; } @@ -496,7 +496,7 @@ uvm_km_alloc1(struct vm_map *map, vsize_t size, vsize_t align, boolean_t zeroit) size -= PAGE_SIZE; } pmap_update(map->pmap); - + /* * zero on request (note that "size" is now zero due to the above loop * so we need to subtract kva from loopva to reconstruct the size). @@ -757,7 +757,7 @@ km_alloc(size_t sz, const struct kmem_va_mode *kv, if (uvm_pglistalloc(sz, kp->kp_constraint->ucr_low, kp->kp_constraint->ucr_high, pla_align, kp->kp_boundary, - &pgl, pla_maxseg, pla_flags)) { + &pgl, pla_maxseg, pla_flags)) { return (NULL); } diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 395151365..ced386a1a 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -4213,7 +4213,7 @@ check_copyin_add(struct vm_map *map, vaddr_t start, vaddr_t end) map->check_copyin_count++; } -/* +/* * uvm_map_check_copyin_add: remember regions which are X-only for copyin(), * copyinstr(), uiomove(), and others * @@ -4235,7 +4235,7 @@ uvm_map_check_copyin_add(struct vm_map *map, vaddr_t start, vaddr_t end) } #endif /* PMAP_CHECK_COPYIN */ -/* +/* * uvm_map_syscall: permit system calls for range of addrs in map. * * => map must be unlocked @@ -4277,7 +4277,7 @@ uvm_map_syscall(struct vm_map *map, vaddr_t start, vaddr_t end) return (0); } -/* +/* * uvm_map_immutable: block mapping/mprotect for range of addrs in map. * * => map must be unlocked @@ -4483,7 +4483,7 @@ uvm_map_extract(struct vm_map *srcmap, vaddr_t start, vsize_t len, } kernel_map->size += cp_len; - /* Figure out the best protection */ + /* Figure out the best protection */ if ((flags & UVM_EXTRACT_FIXPROT) && newentry->protection != PROT_NONE) newentry->protection = newentry->max_protection; diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h index 935333a23..de42336e0 100644 --- a/sys/uvm/uvm_map.h +++ b/sys/uvm/uvm_map.h @@ -16,9 +16,9 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * + * * Copyright (c) 1997 Charles D. Cranor and Washington University. - * Copyright (c) 1991, 1993, The Regents of the University of California. + * Copyright (c) 1991, 1993, The Regents of the University of California. * * All rights reserved. * @@ -55,17 +55,17 @@ * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. - * + * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU @@ -88,7 +88,7 @@ /* * UVM_MAP_CLIP_START: ensure that the entry begins at or after * the starting address, if it doesn't we split the entry. - * + * * => map must be locked by caller */ diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index bab50a86f..8bb23e37f 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -727,7 +727,7 @@ uvm_pagealloc_pg(struct vm_page *pg, struct uvm_object *obj, voff_t off, * low the low address of the allowed allocation range. * high the high address of the allowed allocation range. * alignment memory must be aligned to this power-of-two boundary. - * boundary no segment in the allocation may cross this + * boundary no segment in the allocation may cross this * power-of-two boundary (relative to zero). * => flags: * UVM_PLA_NOWAIT fail if allocation fails diff --git a/sys/uvm/uvm_page.h b/sys/uvm/uvm_page.h index b70ec7d3b..01bac9233 100644 --- a/sys/uvm/uvm_page.h +++ b/sys/uvm/uvm_page.h @@ -1,9 +1,9 @@ /* $OpenBSD: uvm_page.h,v 1.69 2022/08/01 14:15:46 mpi Exp $ */ /* $NetBSD: uvm_page.h,v 1.19 2000/12/28 08:24:55 chs Exp $ */ -/* +/* * Copyright (c) 1997 Charles D. Cranor and Washington University. - * Copyright (c) 1991, 1993, The Regents of the University of California. + * Copyright (c) 1991, 1993, The Regents of the University of California. * * All rights reserved. * @@ -40,17 +40,17 @@ * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. - * + * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU @@ -125,7 +125,7 @@ struct vm_page { /* * locking rules: - * PQ_ ==> lock by page queue lock + * PQ_ ==> lock by page queue lock * PQ_FREE is locked by free queue lock and is mutex with all other PQs * pg_flags may only be changed using the atomic operations. * diff --git a/sys/uvm/uvm_pager.c b/sys/uvm/uvm_pager.c index a348311f5..60c0d79a1 100644 --- a/sys/uvm/uvm_pager.c +++ b/sys/uvm/uvm_pager.c @@ -353,7 +353,7 @@ uvm_mk_pcluster(struct uvm_object *uobj, struct vm_page **pps, int *npages, voff_t lo, hi, curoff; int center_idx, forward, incr; - /* + /* * center page should already be busy and write protected. XXX: * suppose page is wired? if we lock, then a process could * fault/block on it. if we don't lock, a process could write the @@ -381,8 +381,8 @@ uvm_mk_pcluster(struct uvm_object *uobj, struct vm_page **pps, int *npages, *npages = 1; /* - * attempt to cluster around the left [backward], and then - * the right side [forward]. + * attempt to cluster around the left [backward], and then + * the right side [forward]. * * note that for inactive pages (pages that have been deactivated) * there are no valid mappings and PG_CLEAN should be up to date. @@ -451,7 +451,7 @@ uvm_mk_pcluster(struct uvm_object *uobj, struct vm_page **pps, int *npages, (*npages)++; } } - + /* * done! return the cluster array to the caller!!! */ @@ -552,7 +552,7 @@ ReTry: * we have attempted the I/O. * * if the I/O was a success then: - * if !PGO_PDFREECLUST, we return the cluster to the + * if !PGO_PDFREECLUST, we return the cluster to the * caller (who must un-busy all pages) * else we un-busy cluster pages for the pagedaemon * @@ -634,12 +634,12 @@ ReTry: * was one). give up! the caller only has one page ("pg") * to worry about. */ - + return result; } /* - * uvm_pager_dropcluster: drop a cluster we have built (because we + * uvm_pager_dropcluster: drop a cluster we have built (because we * got an error, or, if PGO_PDFREECLUST we are un-busying the * cluster pages on behalf of the pagedaemon). * @@ -649,7 +649,7 @@ ReTry: * => ppsp/npages is our current cluster * => flags: PGO_PDFREECLUST: pageout was a success: un-busy cluster * pages on behalf of the pagedaemon. - * PGO_REALLOCSWAP: drop previously allocated swap slots for + * PGO_REALLOCSWAP: drop previously allocated swap slots for * clustered swap-backed pages (except for "pg" if !NULL) * "swblk" is the start of swap alloc (e.g. for ppsp[0]) * [only meaningful if swap-backed (uobj == NULL)] @@ -668,7 +668,7 @@ uvm_pager_dropcluster(struct uvm_object *uobj, struct vm_page *pg, /* skip "pg" or empty slot */ if (ppsp[lcv] == pg || ppsp[lcv] == NULL) continue; - + /* * Note that PQ_ANON bit can't change as long as we are holding * the PG_BUSY bit (so there is no need to lock the page @@ -711,7 +711,7 @@ uvm_pager_dropcluster(struct uvm_object *uobj, struct vm_page *pg, } /* - * if we are operating on behalf of the pagedaemon and we + * if we are operating on behalf of the pagedaemon and we * had a successful pageout update the page! */ if (flags & PGO_PDFREECLUST) { diff --git a/sys/uvm/uvm_pager.h b/sys/uvm/uvm_pager.h index 3e4946512..bef686ad4 100644 --- a/sys/uvm/uvm_pager.h +++ b/sys/uvm/uvm_pager.h @@ -123,7 +123,7 @@ struct uvm_pagerops { void uvm_pager_dropcluster(struct uvm_object *, struct vm_page *, struct vm_page **, int *, int); void uvm_pager_init(void); -int uvm_pager_put(struct uvm_object *, struct vm_page *, +int uvm_pager_put(struct uvm_object *, struct vm_page *, struct vm_page ***, int *, int, voff_t, voff_t); diff --git a/sys/uvm/uvm_param.h b/sys/uvm/uvm_param.h index d0fe8090e..b8f3af1f9 100644 --- a/sys/uvm/uvm_param.h +++ b/sys/uvm/uvm_param.h @@ -1,7 +1,7 @@ /* $OpenBSD: uvm_param.h,v 1.18 2015/02/07 08:21:24 miod Exp $ */ /* $NetBSD: uvm_param.h,v 1.5 2001/03/09 01:02:12 chs Exp $ */ -/* +/* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index a403c3061..5d1091a75 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -297,7 +297,7 @@ uvm_pageout(void *arg) } if (pma != NULL) { - /* + /* * XXX If UVM_PMA_FREED isn't set, no pages * were freed. Should we set UVM_PMA_FAIL in * that case? @@ -716,7 +716,7 @@ uvmpd_scan_inactive(struct uvm_pmalloc *pma, struct pglist *pglst) * * note locking semantics of uvm_pager_put with PGO_PDFREECLUST: * IN: locked: page queues - * OUT: locked: + * OUT: locked: * !locked: pageqs */ diff --git a/sys/uvm/uvm_pmap.h b/sys/uvm/uvm_pmap.h index c5507ca17..eeb117ff1 100644 --- a/sys/uvm/uvm_pmap.h +++ b/sys/uvm/uvm_pmap.h @@ -1,7 +1,7 @@ /* $OpenBSD: uvm_pmap.h,v 1.33 2023/04/13 15:23:23 miod Exp $ */ /* $NetBSD: uvm_pmap.h,v 1.1 2000/06/27 09:00:14 mrg Exp $ */ -/* +/* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * @@ -39,17 +39,17 @@ * All rights reserved. * * Author: Avadis Tevanian, Jr. - * + * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c index 128772d90..775ea8412 100644 --- a/sys/uvm/uvm_pmemrange.c +++ b/sys/uvm/uvm_pmemrange.c @@ -486,7 +486,7 @@ uvm_pmr_insert(struct uvm_pmemrange *pmr, struct vm_page *pg, int no_join) * => pg: the range at which to start the search. * => boundary: the page number boundary specification (0 = no boundary). * => pmr: the pmemrange of the page. - * + * * This function returns 1 before the next range, so if you want to have the * next range, you need to run TAILQ_NEXT(result, pageq) after calling. * The reason is that this way, the length of the segment is easily @@ -548,7 +548,7 @@ uvm_pmr_findnextsegment(struct uvm_pmemrange *pmr, * => pg: the range at which to start the search. * => boundary: the page number boundary specification (0 = no boundary). * => pmr: the pmemrange of the page. - * + * * This function returns 1 after the previous range, so if you want to have the * previous range, you need to run TAILQ_NEXT(result, pageq) after calling. * The reason is that this way, the length of the segment is easily @@ -1678,7 +1678,7 @@ uvm_pmr_init(void) /* By default, one range for the entire address space. */ new_pmr = uvm_pmr_allocpmr(); new_pmr->low = 0; - new_pmr->high = atop((paddr_t)-1) + 1; + new_pmr->high = atop((paddr_t)-1) + 1; RBT_INSERT(uvm_pmemrange_addr, &uvm.pmr_control.addr, new_pmr); uvm_pmemrange_use_insert(&uvm.pmr_control.use, new_pmr); diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c index 27963259e..593c765aa 100644 --- a/sys/uvm/uvm_swap.c +++ b/sys/uvm/uvm_swap.c @@ -690,7 +690,7 @@ sys_swapctl(struct proc *p, void *v, register_t *retval) if (count >= misc) continue; - sdp->swd_inuse = + sdp->swd_inuse = btodb((u_int64_t)sdp->swd_npginuse << PAGE_SHIFT); error = copyout(&sdp->swd_se, sep, @@ -1963,7 +1963,7 @@ swapmount(void) } else #endif if (bdevvp(swap_dev, &vp)) { - rw_exit_write(&swap_syscall_lock); + rw_exit_write(&swap_syscall_lock); return; } diff --git a/sys/uvm/uvm_swap_encrypt.c b/sys/uvm/uvm_swap_encrypt.c index deb2ff5b6..5f2b6dbb0 100644 --- a/sys/uvm/uvm_swap_encrypt.c +++ b/sys/uvm/uvm_swap_encrypt.c @@ -127,7 +127,7 @@ swap_encrypt(struct swap_key *key, caddr_t src, caddr_t dst, u_int64_t block, count /= sizeof(u_int32_t); iv[0] = block >> 32; iv[1] = block; iv[2] = ~iv[0]; iv[3] = ~iv[1]; - rijndael_encrypt(&swap_ctxt, (u_char *)iv, (u_char *)iv); + rijndael_encrypt(&swap_ctxt, (u_char *)iv, (u_char *)iv); iv1 = iv[0]; iv2 = iv[1]; iv3 = iv[2]; iv4 = iv[3]; for (; count > 0; count -= 4) { @@ -172,7 +172,7 @@ swap_decrypt(struct swap_key *key, caddr_t src, caddr_t dst, u_int64_t block, count /= sizeof(u_int32_t); iv[0] = block >> 32; iv[1] = block; iv[2] = ~iv[0]; iv[3] = ~iv[1]; - rijndael_encrypt(&swap_ctxt, (u_char *)iv, (u_char *)iv); + rijndael_encrypt(&swap_ctxt, (u_char *)iv, (u_char *)iv); iv1 = iv[0]; iv2 = iv[1]; iv3 = iv[2]; iv4 = iv[3]; for (; count > 0; count -= 4) { diff --git a/sys/uvm/uvm_unix.c b/sys/uvm/uvm_unix.c index 3ec0b00a0..a9603ea8b 100644 --- a/sys/uvm/uvm_unix.c +++ b/sys/uvm/uvm_unix.c @@ -3,7 +3,7 @@ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. - * Copyright (c) 1991, 1993 The Regents of the University of California. + * Copyright (c) 1991, 1993 The Regents of the University of California. * Copyright (c) 1988 University of Utah. * * All rights reserved. @@ -320,7 +320,7 @@ uvm_coredump_walkmap(struct proc *p, uvm_coredump_setup_cb *setup, /* * Okay, we have a count in nsegment. Prepare to - * walk it again, then invoke the setup callback. + * walk it again, then invoke the setup callback. */ entry = RBT_MIN(uvm_map_addr, &map->addr); error = (*setup)(nsegment, cookie); diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c index 318aebce5..6d1180019 100644 --- a/sys/uvm/uvm_vnode.c +++ b/sys/uvm/uvm_vnode.c @@ -350,9 +350,9 @@ uvn_detach(struct uvm_object *uobj) /* * given the structure of this pager, the above flush request will * create the following state: all the pages that were in the object - * have either been free'd or they are marked PG_BUSY and in the + * have either been free'd or they are marked PG_BUSY and in the * middle of an async io. If we still have pages we set the "relkill" - * state, so that in the case the vnode gets terminated we know + * state, so that in the case the vnode gets terminated we know * to leave it alone. Otherwise we'll kill the vnode when it's empty. */ uvn->u_flags |= UVM_VNODE_RELKILL; @@ -1491,7 +1491,7 @@ uvm_vnp_sync(struct mount *mp) /* * step 2: build up a simpleq of uvns of interest based on the - * write list. we gain a reference to uvns of interest. + * write list. we gain a reference to uvns of interest. */ SIMPLEQ_INIT(&uvn_sync_q); LIST_FOREACH(uvn, &uvn_wlist, u_wlist) { diff --git a/sys/uvm/uvm_vnode.h b/sys/uvm/uvm_vnode.h index cd10d310f..5e661a486 100644 --- a/sys/uvm/uvm_vnode.h +++ b/sys/uvm/uvm_vnode.h @@ -73,7 +73,7 @@ struct uvm_vnode { #define UVM_VNODE_VALID 0x001 /* we are attached to the vnode */ #define UVM_VNODE_CANPERSIST 0x002 /* we can persist after ref == 0 */ #define UVM_VNODE_ALOCK 0x004 /* uvn_attach is locked out */ -#define UVM_VNODE_DYING 0x008 /* final detach/terminate in +#define UVM_VNODE_DYING 0x008 /* final detach/terminate in progress */ #define UVM_VNODE_RELKILL 0x010 /* uvn should be killed by releasepg when final i/o is done */ diff --git a/usr.bin/libtool/LT/UList.pm b/usr.bin/libtool/LT/UList.pm index 922575e6d..c2f066695 100644 --- a/usr.bin/libtool/LT/UList.pm +++ b/usr.bin/libtool/LT/UList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: UList.pm,v 1.6 2023/07/08 08:45:54 espie Exp $ +# $OpenBSD: UList.pm,v 1.7 2023/07/10 09:29:48 espie Exp $ # # Copyright (c) 2013 Vadim Zhukov # @@ -26,24 +26,24 @@ require Tie::Array; our @ISA = qw(Tie::Array); -sub _translate_num_key +sub _translate_num_key($self, $idx, $offset = 0) { - if ($_[1] < 0) { - $_[1] = @{$_[0]} - (-$_[1]); - die "invalid index" if $_[1] < 1; + if ($idx < 0) { + $idx += @$self; + die "invalid index" if $idx < 1; } else { - $_[1] += 1; + $idx++; } - die "invalid index $_[1]" if $_[1] - int($_[2] // 0) >= @{$_[0]}; + die "invalid index $idx" if $idx - int($offset) >= @$self; + return $idx; } # Construct new UList and returns reference to the array, # not to the tied object itself. -sub new +sub new ($class, @p) { - my $class = shift; - tie(my @a, $class, @_); + tie(my @a, $class, @p); return \@a; } @@ -51,11 +51,10 @@ sub new # self->[0] = { directory => 1 } # self->[1 .. N] = directories in the order of addition, represented as 0..N-1 -sub TIEARRAY +sub TIEARRAY($class, @p) { - my $class = shift; my $self = bless [ {} ], $class; - $self->PUSH(@_); + $self->PUSH(@p); return $self; } @@ -63,101 +62,85 @@ sub TIEARRAY # case we have EXISTS() outta there. So if you really need to check the # presence of particular item, call the method below on the reference # returned by tie() or tied() instead. -sub exists +sub exists($self, $key) { - return exists $_[0]->[0]->{$_[1]}; + return exists $self->[0]{$key}; } -sub indexof +sub indexof($self, $key) { - return exists($_[0]->[0]->{$_[1]}) ? ($_[0]->[0]->{$_[1]} - 1) : undef; + return exists($self->[0]{$key}) ? ($self->[0]{$key} - 1) : undef; } -sub FETCHSIZE +sub FETCHSIZE($self) { - return scalar(@{$_[0]}) - 1; + return scalar(@$self) - 1; } -# not needed ? -sub STORE { - die "unimplemented and should not be used"; +sub STORE($, $, $) +{ + die "overwriting elements is unimplemented"; } -sub DELETE + +sub DELETE($, $) { - die "unimplemented and should not be used"; + die "delete is unimplemented"; } -sub EXTEND -{ -} -sub FETCH +sub FETCH($self, $key) { - my ($self, $key) = (shift, shift); - - # ignore? - die "undef given instead of directory or index" unless defined $key; - - $self->_translate_num_key($key); - return $self->[$key]; + return $self->[$self->_translate_num_key($key)]; } -sub STORESIZE +sub STORESIZE($self, $newsz) { - my ($self, $newsz) = (shift, shift() + 2); + $newsz += 2; my $sz = @$self; if ($newsz > $sz) { # XXX any better way to grow? $self->[$newsz - 1] = undef; } elsif ($newsz < $sz) { - $self->POP() for $newsz .. $sz - 1; + $self->POP for $newsz .. $sz - 1; } } -sub PUSH +sub PUSH($self, @p) { - my $self = shift; - for (@_) { - next if exists $self->[0]->{$_}; - $self->[0]->{$_} = @$self; + for (@p) { + next if exists $self->[0]{$_}; + $self->[0]{$_} = @$self; push(@$self, $_); } } -sub POP +sub POP($self) { - my $self = shift; return undef if @$self < 2; my $key = pop @$self; - delete $self->[0]->{$key}; + delete $self->[0]{$key}; return $key; } -sub SHIFT +sub SHIFT($self) { - my $self = shift; return undef if @$self < 2; my $key = splice(@$self, 1, 1); - delete $self->[0]->{$key}; + delete $self->[0]{$key}; return $key; } -sub UNSHIFT +sub UNSHIFT($self, @p) { - my $self = shift; - $self->SPLICE(0, 0, @_); + $self->SPLICE(0, 0, @p); } -sub SPLICE +sub SPLICE($self, $offset = 0, $length = undef, @p) { - my $self = shift; - - my $offset = shift // 0; - $self->_translate_num_key($offset, 1); + $offset = $self->_translate_num_key($offset, 1); my $maxrm = @$self - $offset; - my $length = shift; if (defined $length) { if ($length < 0) { $length = $maxrm - (-$length); @@ -180,30 +163,30 @@ sub SPLICE my @ret = splice(@$self, $offset, $length); for (@ret) { - delete $self->[0]->{$_}; + delete $self->[0]{$_}; } my $i = 0; my %seen; - for (@_) { + for (@p) { next if exists $seen{$_}; # skip already added items $seen{$_} = 1; - if (exists $self->[0]->{$_}) { - if ($self->[0]->{$_} >= $offset + $length) { + if (exists $self->[0]{$_}) { + if ($self->[0]{$_} >= $offset + $length) { # "move" from tail to new position - splice(@$self, $self->[0]->{$_} - $length + $i, 1); + splice(@$self, $self->[0]{$_} - $length + $i, 1); } else { next; } } splice(@$self, $offset + $i, 0, $_); - $self->[0]->{$_} = $offset + $i; + $self->[0]{$_} = $offset + $i; $i++; $delta++; } - for $i ($offset + scalar(@_) .. @$self - 1) { - $self->[0]->{$self->[$i]} = $i; + for $i ($offset + scalar(@p) .. @$self - 1) { + $self->[0]{$self->[$i]} = $i; } return @ret; @@ -213,8 +196,7 @@ sub SPLICE =head1 test package main; -sub compare_ulists { - my ($list1, $list2) = @_; +sub compare_ulists($list1, $list2) { return 0 if scalar(@$list1) != scalar(@$list2); for my $i (0 .. scalar(@$list1) - 1) { return 0 if $list1->[$i] ne $list2->[$i]; diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c index dfb7695b7..6eeeebe96 100644 --- a/usr.bin/netstat/mbuf.c +++ b/usr.bin/netstat/mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.c,v 1.44 2023/07/07 14:17:35 yasuoka Exp $ */ +/* $OpenBSD: mbuf.c,v 1.45 2023/07/16 03:01:31 yasuoka Exp $ */ /* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */ /* @@ -79,7 +79,7 @@ static struct mbtypes { }; int nmbtypes = sizeof(mbstat.m_mtypes) / sizeof(u_long); -bool seen[256]; /* "have we seen this type yet?" */ +bool seen[MBSTAT_COUNT]; /* "have we seen this type yet?" */ /* * Print mbuf statistics. @@ -93,7 +93,7 @@ mbpr(void) struct mbtypes *mp; size_t size; - if (nmbtypes != 256) { + if (nmbtypes != MBSTAT_COUNT) { fprintf(stderr, "%s: unexpected change to mbstat; check source\n", __progname); diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index b7ff3c513..f621bc84a 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.71 2022/08/03 07:30:37 op Exp $ */ +/* $OpenBSD: patch.c,v 1.74 2023/07/19 13:26:20 tb Exp $ */ /* * patch - a program to apply diffs to original files @@ -99,7 +99,7 @@ static void copy_till(LINENUM, bool); static void spew_output(void); static void dump_line(LINENUM, bool); static bool patch_match(LINENUM, LINENUM, LINENUM); -static bool similar(const char *, const char *, int); +static bool similar(const char *, const char *, ssize_t); static __dead void usage(void); /* true if -E was specified on command line. */ @@ -149,7 +149,7 @@ main(int argc, char *argv[]) const char *tmpdir; char *v; - if (pledge("stdio rpath wpath cpath tmppath fattr", NULL) == -1) { + if (pledge("stdio rpath wpath cpath tmppath fattr unveil", NULL) == -1) { perror("pledge"); my_exit(2); } @@ -204,6 +204,43 @@ main(int argc, char *argv[]) Argc = argc; Argv = argv; get_some_switches(); + if (unveil(tmpdir, "rwc") == -1) { + perror("unveil"); + my_exit(2); + } + if (outname != NULL) + if (unveil(outname, "rwc") == -1) { + perror("unveil"); + my_exit(2); + } + if (filearg[0] != NULL) + if (unveil(filearg[0], "rwc") == -1) { + perror("unveil"); + my_exit(2); + } + if (filearg[1] != NULL) + if (unveil(filearg[1], "r") == -1) { + perror("unveil"); + my_exit(2); + } + if (!force && !batch) + if (unveil(_PATH_TTY, "r") == -1) { + perror("unveil"); + my_exit(2); + } + if (unveil(".", "rwc") == -1) { + perror("unveil"); + my_exit(2); + } + if (*rejname != '\0') + if (unveil(rejname, "rwc") == -1) { + perror("unveil"); + my_exit(2); + } + if (pledge("stdio rpath wpath cpath tmppath fattr", NULL) == -1) { + perror("pledge"); + my_exit(2); + } if (backup_type == none) { if ((v = getenv("PATCH_VERSION_CONTROL")) == NULL) @@ -1012,7 +1049,7 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuzz) LINENUM pat_lines = pch_ptrn_lines() - fuzz; const char *ilineptr; const char *plineptr; - short plinelen; + ssize_t plinelen; for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) { ilineptr = ifetch(iline, offset >= 0); @@ -1048,7 +1085,7 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuzz) * Do two lines match with canonicalized white space? */ static bool -similar(const char *a, const char *b, int len) +similar(const char *a, const char *b, ssize_t len) { while (len) { if (isspace((unsigned char)*b)) { /* whitespace (or \n) to match? */ diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index 256f46cc4..5baef3cf3 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pch.c,v 1.63 2022/12/26 19:16:02 jmc Exp $ */ +/* $OpenBSD: pch.c,v 1.66 2023/07/12 15:45:34 florian Exp $ */ /* * patch - a program to apply diffs to original files @@ -56,7 +56,7 @@ static LINENUM p_end = -1; /* last line in hunk */ static LINENUM p_max; /* max allowed value of p_end */ static LINENUM p_context = 3; /* # of context lines */ static char **p_line = NULL;/* the text of the hunk */ -static short *p_len = NULL; /* length of each line */ +static ssize_t *p_len = NULL; /* length of each line */ static char *p_char = NULL; /* +, -, and ! */ static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */ static int p_indent; /* indent to patch */ @@ -127,7 +127,7 @@ set_hunkmax(void) if (p_line == NULL) p_line = calloc((size_t) hunkmax, sizeof(char *)); if (p_len == NULL) - p_len = calloc((size_t) hunkmax, sizeof(short)); + p_len = calloc((size_t) hunkmax, sizeof(ssize_t)); if (p_char == NULL) p_char = calloc((size_t) hunkmax, sizeof(char)); } @@ -140,7 +140,7 @@ grow_hunkmax(void) { int new_hunkmax; char **new_p_line; - short *new_p_len; + ssize_t *new_p_len; char *new_p_char; new_hunkmax = hunkmax * 2; @@ -152,7 +152,7 @@ grow_hunkmax(void) if (new_p_line == NULL) free(p_line); - new_p_len = reallocarray(p_len, new_hunkmax, sizeof(short)); + new_p_len = reallocarray(p_len, new_hunkmax, sizeof(ssize_t)); if (new_p_len == NULL) free(p_len); @@ -1192,7 +1192,7 @@ bool pch_swap(void) { char **tp_line; /* the text of the hunk */ - short *tp_len; /* length of each line */ + ssize_t *tp_len; /* length of each line */ char *tp_char; /* +, -, and ! */ LINENUM i; LINENUM n; @@ -1349,7 +1349,7 @@ pch_context(void) /* * Return the length of a particular patch line. */ -short +ssize_t pch_line_len(LINENUM line) { return p_len[line]; @@ -1422,7 +1422,7 @@ compare_names(const struct file_name *names, bool assume_exists) { size_t min_components, min_baselen, min_len, tmp; char *best = NULL; - char *path; + char *path, *bn; int i; /* @@ -1443,7 +1443,10 @@ compare_names(const struct file_name *names, bool assume_exists) min_components = tmp; best = path; } - if ((tmp = strlen(basename(path))) > min_baselen) + bn = basename(path); + if (bn == NULL) + continue; + if ((tmp = strlen(bn)) > min_baselen) continue; if (tmp < min_baselen) { min_baselen = tmp; @@ -1481,7 +1484,8 @@ num_components(const char *path) size_t n; const char *cp; - for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++, cp++) { + for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++) { + cp++; while (*cp == '/') cp++; /* skip consecutive slashes */ } diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h index 1ce9713d9..96980bb26 100644 --- a/usr.bin/patch/pch.h +++ b/usr.bin/patch/pch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pch.h,v 1.13 2019/12/11 20:10:17 jca Exp $ */ +/* $OpenBSD: pch.h,v 1.14 2023/07/12 11:26:13 tb Exp $ */ /* * patch - a program to apply diffs to original files @@ -53,7 +53,7 @@ LINENUM pch_newfirst(void); LINENUM pch_repl_lines(void); LINENUM pch_end(void); LINENUM pch_context(void); -short pch_line_len(LINENUM); +ssize_t pch_line_len(LINENUM); char pch_char(LINENUM); char *pfetch(LINENUM); LINENUM pch_hunk_beg(void); diff --git a/usr.bin/ssh/PROTOCOL.krl b/usr.bin/ssh/PROTOCOL.krl index 115f80e5d..1b59c76be 100644 --- a/usr.bin/ssh/PROTOCOL.krl +++ b/usr.bin/ssh/PROTOCOL.krl @@ -37,6 +37,7 @@ The available section types are: #define KRL_SECTION_FINGERPRINT_SHA1 3 #define KRL_SECTION_SIGNATURE 4 #define KRL_SECTION_FINGERPRINT_SHA256 5 +#define KRL_SECTION_EXTENSION 255 2. Certificate section @@ -64,6 +65,7 @@ The certificate section types are: #define KRL_SECTION_CERT_SERIAL_RANGE 0x21 #define KRL_SECTION_CERT_SERIAL_BITMAP 0x22 #define KRL_SECTION_CERT_KEY_ID 0x23 +#define KRL_SECTION_CERT_EXTENSION 0x39 2.1 Certificate serial list section @@ -114,6 +116,29 @@ associated with a particular identity, e.g. a host or a user. This section must contain at least one "key_id". This section may appear multiple times. +2.5. Certificate Extension subsections + +This subsection type provides a generic extension mechanism to the +certificates KRL section that may be used to provide optional or critical +data. + +Extensions are stored in subsections of type +KRL_SECTION_CERT_EXTENSION with the following contents: + + string extension_name + boolean is_critical + string extension_contents. + +Where "extension_name" describes the type of extension. It is +recommended that user extensions follow "cert-name@domain.org" naming. + +The "is_critical" indicates whether this extension is mandatory or +optional. If true, then any unsupported extension encountered should +result in KRL parsing failure. If false, then it may be safely be +ignored. + +The "extension_contents" contains the body of the extension. + 3. Explicit key sections These sections, identified as KRL_SECTION_EXPLICIT_KEY, revoke keys @@ -144,7 +169,33 @@ as a big-endian integer. This section may appear multiple times. -5. KRL signature sections +5. Extension sections + +This section type provides a generic extension mechanism to the KRL +format that may be used to provide optional or critical data. + +Extensions are recorded in sections of type KRL_SECTION_EXTENSION +with the following contents: + + string extension_name + boolean is_critical + string extension_contents. + +Where "extension_name" describes the type of extension. It is +recommended that user extensions follow "name@domain.org" naming. + +The "is_critical" indicates whether this extension is mandatory or +optional. If true, then any unsupported extension encountered should +result in KRL parsing failure. If false, then it may be safely be +ignored. + +The "extension_contents" contains the body of the extension. + +6. KRL signature sections + +Note: KRL signatures are not supported by OpenSSH. OpenSSH >= 9.4 will +refuse to load KRLs that contain signatures. We recommend the use +of SSHSIG (`ssh-keygen -Y sign ...`) style signatures for KRLs instead. The KRL_SECTION_SIGNATURE section serves a different purpose to the preceding ones: to provide cryptographic authentication of a KRL that @@ -168,4 +219,4 @@ Implementations that retrieve KRLs over untrusted channels must verify signatures. Signature sections are optional for KRLs distributed by trusted means. -$OpenBSD: PROTOCOL.krl,v 1.5 2018/09/12 01:21:34 djm Exp $ +$OpenBSD: PROTOCOL.krl,v 1.7 2023/07/17 04:01:10 djm Exp $ diff --git a/usr.bin/ssh/auth-options.c b/usr.bin/ssh/auth-options.c index 177a221f1..ee5ec7ecf 100644 --- a/usr.bin/ssh/auth-options.c +++ b/usr.bin/ssh/auth-options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth-options.c,v 1.99 2023/03/29 00:18:35 djm Exp $ */ +/* $OpenBSD: auth-options.c,v 1.101 2023/07/14 07:44:21 dtucker Exp $ */ /* * Copyright (c) 2018 Damien Miller * @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -45,10 +46,11 @@ dup_strings(char ***dstp, size_t *ndstp, char **src, size_t nsrc) *dstp = NULL; *ndstp = 0; + if (nsrc == 0) return 0; - - if ((dst = calloc(nsrc, sizeof(*src))) == NULL) + if (nsrc >= SIZE_MAX / sizeof(*src) || + (dst = calloc(nsrc, sizeof(*src))) == NULL) return -1; for (i = 0; i < nsrc; i++) { if ((dst[i] = strdup(src[i])) == NULL) { diff --git a/usr.bin/ssh/chacha.c b/usr.bin/ssh/chacha.c index 74221ec6b..1305bda6d 100644 --- a/usr.bin/ssh/chacha.c +++ b/usr.bin/ssh/chacha.c @@ -1,3 +1,4 @@ +/* $OpenBSD: chacha.c,v 1.2 2023/07/17 05:26:38 djm Exp $ */ /* chacha-merged.c version 20080118 D. J. Bernstein @@ -6,8 +7,6 @@ Public domain. #include "chacha.h" -/* $OpenBSD: chacha.c,v 1.1 2013/11/21 00:45:44 djm Exp $ */ - typedef unsigned char u8; typedef unsigned int u32; diff --git a/usr.bin/ssh/cipher-chachapoly-libcrypto.c b/usr.bin/ssh/cipher-chachapoly-libcrypto.c index d289cf23d..bff06b74a 100644 --- a/usr.bin/ssh/cipher-chachapoly-libcrypto.c +++ b/usr.bin/ssh/cipher-chachapoly-libcrypto.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cipher-chachapoly-libcrypto.c,v 1.2 2023/07/17 05:26:38 djm Exp $ */ /* * Copyright (c) 2013 Damien Miller * @@ -14,8 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: cipher-chachapoly-libcrypto.c,v 1.1 2020/04/03 04:32:21 djm Exp $ */ - #include #include /* needed for log.h */ #include diff --git a/usr.bin/ssh/cipher-chachapoly.c b/usr.bin/ssh/cipher-chachapoly.c index 05c0c916c..8274368f8 100644 --- a/usr.bin/ssh/cipher-chachapoly.c +++ b/usr.bin/ssh/cipher-chachapoly.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cipher-chachapoly.c,v 1.10 2023/07/17 05:26:38 djm Exp $ */ /* * Copyright (c) 2013 Damien Miller * @@ -14,8 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: cipher-chachapoly.c,v 1.9 2020/04/03 04:27:03 djm Exp $ */ - #include #include /* needed for log.h */ #include diff --git a/usr.bin/ssh/krl.c b/usr.bin/ssh/krl.c index 6c4e372bc..51a287166 100644 --- a/usr.bin/ssh/krl.c +++ b/usr.bin/ssh/krl.c @@ -1,3 +1,4 @@ +/* $OpenBSD: krl.c,v 1.59 2023/07/17 05:22:30 djm Exp $ */ /* * Copyright (c) 2012 Damien Miller * @@ -14,8 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: krl.c,v 1.55 2023/03/14 07:28:47 dtucker Exp $ */ - #include #include #include @@ -727,15 +726,13 @@ revoked_certs_generate(struct revoked_certs *rc, struct sshbuf *buf) } int -ssh_krl_to_blob(struct ssh_krl *krl, struct sshbuf *buf, - struct sshkey **sign_keys, u_int nsign_keys) +ssh_krl_to_blob(struct ssh_krl *krl, struct sshbuf *buf) { int r = SSH_ERR_INTERNAL_ERROR; struct revoked_certs *rc; struct revoked_blob *rb; struct sshbuf *sect; u_char *sblob = NULL; - size_t slen, i; if (krl->generated_date == 0) krl->generated_date = time(NULL); @@ -799,22 +796,7 @@ ssh_krl_to_blob(struct ssh_krl *krl, struct sshbuf *buf, (r = sshbuf_put_stringb(buf, sect)) != 0) goto out; } - - for (i = 0; i < nsign_keys; i++) { - KRL_DBG(("sig key %s", sshkey_ssh_name(sign_keys[i]))); - if ((r = sshbuf_put_u8(buf, KRL_SECTION_SIGNATURE)) != 0 || - (r = sshkey_puts(sign_keys[i], buf)) != 0) - goto out; - /* XXX support sk-* keys */ - if ((r = sshkey_sign(sign_keys[i], &sblob, &slen, - sshbuf_ptr(buf), sshbuf_len(buf), NULL, NULL, - NULL, 0)) != 0) - goto out; - KRL_DBG(("signature sig len %zu", slen)); - if ((r = sshbuf_put_string(buf, sblob, slen)) != 0) - goto out; - } - + /* success */ r = 0; out: free(sblob); @@ -838,6 +820,45 @@ format_timestamp(u_int64_t timestamp, char *ts, size_t nts) } } +static int +cert_extension_subsection(struct sshbuf *subsect, struct ssh_krl *krl) +{ + int r = SSH_ERR_INTERNAL_ERROR; + u_char critical = 1; + struct sshbuf *value = NULL; + char *name = NULL; + + if ((r = sshbuf_get_cstring(subsect, &name, NULL)) != 0 || + (r = sshbuf_get_u8(subsect, &critical)) != 0 || + (r = sshbuf_froms(subsect, &value)) != 0) { + debug_fr(r, "parse"); + error("KRL has invalid certificate extension subsection"); + r = SSH_ERR_INVALID_FORMAT; + goto out; + } + if (sshbuf_len(subsect) != 0) { + error("KRL has invalid certificate extension subsection: " + "trailing data"); + r = SSH_ERR_INVALID_FORMAT; + goto out; + } + debug_f("cert extension %s critical %u len %zu", + name, critical, sshbuf_len(value)); + /* no extensions are currently supported */ + if (critical) { + error("KRL contains unsupported critical certificate " + "subsection \"%s\"", name); + r = SSH_ERR_FEATURE_UNSUPPORTED; + goto out; + } + /* success */ + r = 0; + out: + free(name); + sshbuf_free(value); + return r; +} + static int parse_revoked_certs(struct sshbuf *buf, struct ssh_krl *krl) { @@ -929,6 +950,10 @@ parse_revoked_certs(struct sshbuf *buf, struct ssh_krl *krl) key_id = NULL; } break; + case KRL_SECTION_CERT_EXTENSION: + if ((r = cert_extension_subsection(subsect, krl)) != 0) + goto out; + break; default: error("Unsupported KRL certificate section %u", type); r = SSH_ERR_INVALID_FORMAT; @@ -975,45 +1000,76 @@ blob_section(struct sshbuf *sect, struct revoked_blob_tree *target_tree, return 0; } -/* Attempt to parse a KRL, checking its signature (if any) with sign_ca_keys. */ +static int +extension_section(struct sshbuf *sect, struct ssh_krl *krl) +{ + int r = SSH_ERR_INTERNAL_ERROR; + u_char critical = 1; + struct sshbuf *value = NULL; + char *name = NULL; + + if ((r = sshbuf_get_cstring(sect, &name, NULL)) != 0 || + (r = sshbuf_get_u8(sect, &critical)) != 0 || + (r = sshbuf_froms(sect, &value)) != 0) { + debug_fr(r, "parse"); + error("KRL has invalid extension section"); + r = SSH_ERR_INVALID_FORMAT; + goto out; + } + if (sshbuf_len(sect) != 0) { + error("KRL has invalid extension section: trailing data"); + r = SSH_ERR_INVALID_FORMAT; + goto out; + } + debug_f("extension %s critical %u len %zu", + name, critical, sshbuf_len(value)); + /* no extensions are currently supported */ + if (critical) { + error("KRL contains unsupported critical section \"%s\"", name); + r = SSH_ERR_FEATURE_UNSUPPORTED; + goto out; + } + /* success */ + r = 0; + out: + free(name); + sshbuf_free(value); + return r; +} + +/* Attempt to parse a KRL */ int -ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp, - const struct sshkey **sign_ca_keys, size_t nsign_ca_keys) +ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp) { struct sshbuf *copy = NULL, *sect = NULL; struct ssh_krl *krl = NULL; char timestamp[64]; - int r = SSH_ERR_INTERNAL_ERROR, sig_seen; - struct sshkey *key = NULL, **ca_used = NULL, **tmp_ca_used; + int r = SSH_ERR_INTERNAL_ERROR; u_char type; - const u_char *blob; - size_t i, j, sig_off, sects_off, blen, nca_used; u_int format_version; - nca_used = 0; *krlp = NULL; - if (sshbuf_len(buf) < sizeof(KRL_MAGIC) - 1 || - memcmp(sshbuf_ptr(buf), KRL_MAGIC, sizeof(KRL_MAGIC) - 1) != 0) { - debug3_f("not a KRL"); + + /* KRL must begin with magic string */ + if ((r = sshbuf_cmp(buf, 0, KRL_MAGIC, sizeof(KRL_MAGIC) - 1)) != 0) { + debug2_f("bad KRL magic header"); return SSH_ERR_KRL_BAD_MAGIC; } - /* Take a copy of the KRL buffer so we can verify its signature later */ - if ((copy = sshbuf_fromb(buf)) == NULL) { - r = SSH_ERR_ALLOC_FAIL; - goto out; - } - if ((r = sshbuf_consume(copy, sizeof(KRL_MAGIC) - 1)) != 0) - goto out; - if ((krl = ssh_krl_init()) == NULL) { error_f("alloc failed"); goto out; } - - if ((r = sshbuf_get_u32(copy, &format_version)) != 0) + /* Don't modify buffer */ + if ((copy = sshbuf_fromb(buf)) == NULL) { + r = SSH_ERR_ALLOC_FAIL; + goto out; + } + if ((r = sshbuf_consume(copy, sizeof(KRL_MAGIC) - 1)) != 0 || + (r = sshbuf_get_u32(copy, &format_version)) != 0) goto out; if (format_version != KRL_FORMAT_VERSION) { + error_f("unsupported KRL format version %u", format_version); r = SSH_ERR_INVALID_FORMAT; goto out; } @@ -1021,106 +1077,23 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp, (r = sshbuf_get_u64(copy, &krl->generated_date)) != 0 || (r = sshbuf_get_u64(copy, &krl->flags)) != 0 || (r = sshbuf_skip_string(copy)) != 0 || - (r = sshbuf_get_cstring(copy, &krl->comment, NULL)) != 0) + (r = sshbuf_get_cstring(copy, &krl->comment, NULL)) != 0) { + error_fr(r, "parse KRL header"); goto out; - + } format_timestamp(krl->generated_date, timestamp, sizeof(timestamp)); debug("KRL version %llu generated at %s%s%s", (long long unsigned)krl->krl_version, timestamp, *krl->comment ? ": " : "", krl->comment); - /* - * 1st pass: verify signatures, if any. This is done to avoid - * detailed parsing of data whose provenance is unverified. - */ - sig_seen = 0; - if (sshbuf_len(buf) < sshbuf_len(copy)) { - /* Shouldn't happen */ - r = SSH_ERR_INTERNAL_ERROR; - goto out; - } - sects_off = sshbuf_len(buf) - sshbuf_len(copy); - while (sshbuf_len(copy) > 0) { - if ((r = sshbuf_get_u8(copy, &type)) != 0 || - (r = sshbuf_get_string_direct(copy, &blob, &blen)) != 0) - goto out; - KRL_DBG(("first pass, section 0x%02x", type)); - if (type != KRL_SECTION_SIGNATURE) { - if (sig_seen) { - error("KRL contains non-signature section " - "after signature"); - r = SSH_ERR_INVALID_FORMAT; - goto out; - } - /* Not interested for now. */ - continue; - } - sig_seen = 1; - /* First string component is the signing key */ - if ((r = sshkey_from_blob(blob, blen, &key)) != 0) { - r = SSH_ERR_INVALID_FORMAT; - goto out; - } - if (sshbuf_len(buf) < sshbuf_len(copy)) { - /* Shouldn't happen */ - r = SSH_ERR_INTERNAL_ERROR; - goto out; - } - sig_off = sshbuf_len(buf) - sshbuf_len(copy); - /* Second string component is the signature itself */ - if ((r = sshbuf_get_string_direct(copy, &blob, &blen)) != 0) { - r = SSH_ERR_INVALID_FORMAT; - goto out; - } - /* Check signature over entire KRL up to this point */ - if ((r = sshkey_verify(key, blob, blen, - sshbuf_ptr(buf), sig_off, NULL, 0, NULL)) != 0) - goto out; - /* Check if this key has already signed this KRL */ - for (i = 0; i < nca_used; i++) { - if (sshkey_equal(ca_used[i], key)) { - error("KRL signed more than once with " - "the same key"); - r = SSH_ERR_INVALID_FORMAT; - goto out; - } - } - /* Record keys used to sign the KRL */ - tmp_ca_used = recallocarray(ca_used, nca_used, nca_used + 1, - sizeof(*ca_used)); - if (tmp_ca_used == NULL) { - r = SSH_ERR_ALLOC_FAIL; - goto out; - } - ca_used = tmp_ca_used; - ca_used[nca_used++] = key; - key = NULL; - } - - if (sshbuf_len(copy) != 0) { - /* Shouldn't happen */ - r = SSH_ERR_INTERNAL_ERROR; - goto out; - } - - /* - * 2nd pass: parse and load the KRL, skipping the header to the point - * where the section start. - */ - sshbuf_free(copy); - if ((copy = sshbuf_fromb(buf)) == NULL) { - r = SSH_ERR_ALLOC_FAIL; - goto out; - } - if ((r = sshbuf_consume(copy, sects_off)) != 0) - goto out; + /* Parse and load the KRL sections. */ while (sshbuf_len(copy) > 0) { sshbuf_free(sect); sect = NULL; if ((r = sshbuf_get_u8(copy, &type)) != 0 || (r = sshbuf_froms(copy, §)) != 0) goto out; - KRL_DBG(("second pass, section 0x%02x", type)); + KRL_DBG(("section 0x%02x", type)); switch (type) { case KRL_SECTION_CERTIFICATES: @@ -1142,6 +1115,10 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp, &krl->revoked_sha256s, 32)) != 0) goto out; break; + case KRL_SECTION_EXTENSION: + if ((r = extension_section(sect, krl)) != 0) + goto out; + break; case KRL_SECTION_SIGNATURE: /* Handled above, but still need to stay in synch */ sshbuf_free(sect); @@ -1161,51 +1138,12 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp, } } - /* Check that the key(s) used to sign the KRL weren't revoked */ - sig_seen = 0; - for (i = 0; i < nca_used; i++) { - if (ssh_krl_check_key(krl, ca_used[i]) == 0) - sig_seen = 1; - else { - sshkey_free(ca_used[i]); - ca_used[i] = NULL; - } - } - if (nca_used && !sig_seen) { - error("All keys used to sign KRL were revoked"); - r = SSH_ERR_KEY_REVOKED; - goto out; - } - - /* If we have CA keys, then verify that one was used to sign the KRL */ - if (sig_seen && nsign_ca_keys != 0) { - sig_seen = 0; - for (i = 0; !sig_seen && i < nsign_ca_keys; i++) { - for (j = 0; j < nca_used; j++) { - if (ca_used[j] == NULL) - continue; - if (sshkey_equal(ca_used[j], sign_ca_keys[i])) { - sig_seen = 1; - break; - } - } - } - if (!sig_seen) { - r = SSH_ERR_SIGNATURE_INVALID; - error("KRL not signed with any trusted key"); - goto out; - } - } - + /* Success */ *krlp = krl; r = 0; out: if (r != 0) ssh_krl_free(krl); - for (i = 0; i < nca_used; i++) - sshkey_free(ca_used[i]); - free(ca_used); - sshkey_free(key); sshbuf_free(copy); sshbuf_free(sect); return r; @@ -1339,7 +1277,7 @@ ssh_krl_file_contains_key(const char *path, const struct sshkey *key) oerrno = errno; goto out; } - if ((r = ssh_krl_from_blob(krlbuf, &krl, NULL, 0)) != 0) + if ((r = ssh_krl_from_blob(krlbuf, &krl)) != 0) goto out; debug2_f("checking KRL %s", path); r = ssh_krl_check_key(krl, key); diff --git a/usr.bin/ssh/krl.h b/usr.bin/ssh/krl.h index ca6d3f284..eb244767b 100644 --- a/usr.bin/ssh/krl.h +++ b/usr.bin/ssh/krl.h @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: krl.h,v 1.8 2020/04/03 02:26:56 djm Exp $ */ +/* $OpenBSD: krl.h,v 1.10 2023/07/17 04:01:10 djm Exp $ */ #ifndef _KRL_H #define _KRL_H @@ -30,12 +30,14 @@ #define KRL_SECTION_FINGERPRINT_SHA1 3 #define KRL_SECTION_SIGNATURE 4 #define KRL_SECTION_FINGERPRINT_SHA256 5 +#define KRL_SECTION_EXTENSION 255 /* KRL_SECTION_CERTIFICATES subsection types */ #define KRL_SECTION_CERT_SERIAL_LIST 0x20 #define KRL_SECTION_CERT_SERIAL_RANGE 0x21 #define KRL_SECTION_CERT_SERIAL_BITMAP 0x22 #define KRL_SECTION_CERT_KEY_ID 0x23 +#define KRL_SECTION_CERT_EXTENSION 0x39 struct sshkey; struct sshbuf; @@ -55,10 +57,8 @@ int ssh_krl_revoke_key_explicit(struct ssh_krl *krl, const struct sshkey *key); int ssh_krl_revoke_key_sha1(struct ssh_krl *krl, const u_char *p, size_t len); int ssh_krl_revoke_key_sha256(struct ssh_krl *krl, const u_char *p, size_t len); int ssh_krl_revoke_key(struct ssh_krl *krl, const struct sshkey *key); -int ssh_krl_to_blob(struct ssh_krl *krl, struct sshbuf *buf, - struct sshkey **sign_keys, u_int nsign_keys); -int ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp, - const struct sshkey **sign_ca_keys, size_t nsign_ca_keys); +int ssh_krl_to_blob(struct ssh_krl *krl, struct sshbuf *buf); +int ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp); int ssh_krl_check_key(struct ssh_krl *krl, const struct sshkey *key); int ssh_krl_file_contains_key(const char *path, const struct sshkey *key); int krl_dump(struct ssh_krl *krl, FILE *f); diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c index a9b5da709..3f5ed04b9 100644 --- a/usr.bin/ssh/misc.c +++ b/usr.bin/ssh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.181 2023/03/03 02:37:58 dtucker Exp $ */ +/* $OpenBSD: misc.c,v 1.184 2023/07/19 14:02:27 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005-2020 Damien Miller. All rights reserved. @@ -40,10 +40,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -879,8 +881,11 @@ urldecode(const char *src) { char *ret, *dst; int ch; + size_t srclen; - ret = xmalloc(strlen(src) + 1); + if ((srclen = strlen(src)) >= SIZE_MAX) + fatal_f("input too large"); + ret = xmalloc(srclen + 1); for (dst = ret; *src != '\0'; src++) { switch (*src) { case '+': @@ -2810,3 +2815,31 @@ ptimeout_isset(struct timespec *pt) { return pt->tv_sec != -1; } + +/* + * Returns zero if the library at 'path' contains symbol 's', nonzero + * otherwise. + */ +int +lib_contains_symbol(const char *path, const char *s) +{ + struct nlist nl[2]; + int ret = -1, r; + + memset(nl, 0, sizeof(nl)); + nl[0].n_name = xstrdup(s); + nl[1].n_name = NULL; + if ((r = nlist(path, nl)) == -1) { + error_f("nlist failed for %s", path); + goto out; + } + if (r != 0 || nl[0].n_value == 0 || nl[0].n_type == 0) { + error_f("library %s does not contain symbol %s", path, s); + goto out; + } + /* success */ + ret = 0; + out: + free(nl[0].n_name); + return ret; +} diff --git a/usr.bin/ssh/misc.h b/usr.bin/ssh/misc.h index 902cf56cb..94082238d 100644 --- a/usr.bin/ssh/misc.h +++ b/usr.bin/ssh/misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.h,v 1.102 2023/03/03 02:37:58 dtucker Exp $ */ +/* $OpenBSD: misc.h,v 1.103 2023/07/19 14:02:27 djm Exp $ */ /* * Author: Tatu Ylonen @@ -96,6 +96,7 @@ int parse_absolute_time(const char *, uint64_t *); void format_absolute_time(uint64_t, char *, size_t); int path_absolute(const char *); int stdfd_devnull(int, int, int); +int lib_contains_symbol(const char *, const char *); struct passwd *pwcopy(struct passwd *); const char *ssh_gai_strerror(int); diff --git a/usr.bin/ssh/poly1305.c b/usr.bin/ssh/poly1305.c index ee4d5954e..ead974177 100644 --- a/usr.bin/ssh/poly1305.c +++ b/usr.bin/ssh/poly1305.c @@ -1,10 +1,9 @@ -/* +/* $OpenBSD: poly1305.c,v 1.4 2023/07/17 05:26:38 djm Exp $ */ +/* * Public Domain poly1305 from Andrew Moon * poly1305-donna-unrolled.c from https://github.com/floodyberry/poly1305-donna */ -/* $OpenBSD: poly1305.c,v 1.3 2013/12/19 22:57:13 djm Exp $ */ - #include #include diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c index de70683e5..ed1199811 100644 --- a/usr.bin/ssh/readconf.c +++ b/usr.bin/ssh/readconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.c,v 1.377 2023/06/21 05:10:26 djm Exp $ */ +/* $OpenBSD: readconf.c,v 1.380 2023/07/17 06:16:33 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -126,7 +128,7 @@ static int process_config_line_depth(Options *options, struct passwd *pw, typedef enum { oBadOption, - oHost, oMatch, oInclude, + oHost, oMatch, oInclude, oTag, oForwardAgent, oForwardX11, oForwardX11Trusted, oForwardX11Timeout, oGatewayPorts, oExitOnForwardFailure, oPasswordAuthentication, @@ -239,6 +241,7 @@ static struct { { "user", oUser }, { "host", oHost }, { "match", oMatch }, + { "tag", oTag }, { "escapechar", oEscapeChar }, { "globalknownhostsfile", oGlobalKnownHostsFile }, { "userknownhostsfile", oUserKnownHostsFile }, @@ -562,6 +565,60 @@ execute_in_shell(const char *cmd) return WEXITSTATUS(status); } +/* + * Check whether a local network interface address appears in CIDR pattern- + * list 'addrlist'. Returns 1 if matched or 0 otherwise. + */ +static int +check_match_ifaddrs(const char *addrlist) +{ + struct ifaddrs *ifa, *ifaddrs = NULL; + int r, found = 0; + char addr[NI_MAXHOST]; + socklen_t salen; + + if (getifaddrs(&ifaddrs) != 0) { + error("match localnetwork: getifaddrs failed: %s", + strerror(errno)); + return 0; + } + for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { + if (ifa->ifa_addr == NULL || ifa->ifa_name == NULL || + (ifa->ifa_flags & IFF_UP) == 0) + continue; + switch (ifa->ifa_addr->sa_family) { + case AF_INET: + salen = sizeof(struct sockaddr_in); + break; + case AF_INET6: + salen = sizeof(struct sockaddr_in6); + break; + case AF_LINK: + /* ignore */ + continue; + default: + debug2_f("interface %s: unsupported address family %d", + ifa->ifa_name, ifa->ifa_addr->sa_family); + continue; + } + if ((r = getnameinfo(ifa->ifa_addr, salen, addr, sizeof(addr), + NULL, 0, NI_NUMERICHOST)) != 0) { + debug2_f("interface %s getnameinfo failed: %s", + ifa->ifa_name, gai_strerror(r)); + continue; + } + debug3_f("interface %s addr %s", ifa->ifa_name, addr); + if (addr_match_cidr_list(addr, addrlist) == 1) { + debug3_f("matched interface %s: address %s in %s", + ifa->ifa_name, addr, addrlist); + found = 1; + break; + } + } + freeifaddrs(ifaddrs); + return found; +} + /* * Parse and execute a Match directive. */ @@ -666,6 +723,21 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw, r = match_pattern_list(pw->pw_name, arg, 0) == 1; if (r == (negate ? 1 : 0)) this_result = result = 0; + } else if (strcasecmp(attrib, "localnetwork") == 0) { + if (addr_match_cidr_list(NULL, arg) == -1) { + /* Error already printed */ + result = -1; + goto out; + } + r = check_match_ifaddrs(arg) == 1; + if (r == (negate ? 1 : 0)) + this_result = result = 0; + } else if (strcasecmp(attrib, "tagged") == 0) { + criteria = xstrdup(options->tag == NULL ? "" : + options->tag); + r = match_pattern_list(criteria, arg, 0) == 1; + if (r == (negate ? 1 : 0)) + this_result = result = 0; } else if (strcasecmp(attrib, "exec") == 0) { char *conn_hash_hex, *keyalias; @@ -719,9 +791,11 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw, result = -1; goto out; } - debug3("%.200s line %d: %smatched '%s \"%.100s\"' ", - filename, linenum, this_result ? "": "not ", - oattrib, criteria); + debug3("%.200s line %d: %smatched '%s%s%.100s%s' ", + filename, linenum, this_result ? "": "not ", oattrib, + criteria == NULL ? "" : " \"", + criteria == NULL ? "" : criteria, + criteria == NULL ? "" : "\""); free(criteria); } if (attributes == 0) { @@ -1282,6 +1356,10 @@ parse_char_array: charptr = &options->hostname; goto parse_string; + case oTag: + charptr = &options->tag; + goto parse_string; + case oHostKeyAlias: charptr = &options->host_key_alias; goto parse_string; @@ -2429,6 +2507,7 @@ initialize_options(Options * options) options->known_hosts_command = NULL; options->required_rsa_size = -1; options->enable_escape_commandline = -1; + options->tag = NULL; } /* @@ -3341,6 +3420,7 @@ dump_client_config(Options *o, const char *host) dump_cfg_string(oRevokedHostKeys, o->revoked_host_keys); dump_cfg_string(oXAuthLocation, o->xauth_location); dump_cfg_string(oKnownHostsCommand, o->known_hosts_command); + dump_cfg_string(oTag, o->tag); /* Forwards */ dump_cfg_forwards(oDynamicForward, o->num_local_forwards, o->local_forwards); diff --git a/usr.bin/ssh/readconf.h b/usr.bin/ssh/readconf.h index 2ce1b4c33..dfe5bab0a 100644 --- a/usr.bin/ssh/readconf.h +++ b/usr.bin/ssh/readconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.h,v 1.150 2023/01/13 02:58:20 dtucker Exp $ */ +/* $OpenBSD: readconf.h,v 1.151 2023/07/17 04:08:31 djm Exp $ */ /* * Author: Tatu Ylonen @@ -70,6 +70,7 @@ typedef struct { char *kex_algorithms; /* SSH2 kex methods in order of preference. */ char *ca_sign_algorithms; /* Allowed CA signature algorithms */ char *hostname; /* Real host to connect. */ + char *tag; /* Configuration tag name. */ char *host_key_alias; /* hostname alias for .ssh/known_hosts */ char *proxy_command; /* Proxy command for connecting the host. */ char *user; /* User to log in as. */ diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c index 5baab2e87..3a279a105 100644 --- a/usr.bin/ssh/scp.c +++ b/usr.bin/ssh/scp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.256 2023/03/31 05:56:36 dtucker Exp $ */ +/* $OpenBSD: scp.c,v 1.257 2023/07/14 05:31:44 djm Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -777,8 +777,13 @@ emit_expansion(const char *pattern, int brace_start, int brace_end, int sel_start, int sel_end, char ***patternsp, size_t *npatternsp) { char *cp; - int o = 0, tail_len = strlen(pattern + brace_end + 1); + size_t pattern_len; + int o = 0, tail_len; + if ((pattern_len = strlen(pattern)) == 0 || pattern_len >= INT_MAX) + return -1; + + tail_len = strlen(pattern + brace_end + 1); if ((cp = malloc(brace_start + (sel_end - sel_start) + tail_len + 1)) == NULL) return -1; diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c index 1cf331629..d8a652ddf 100644 --- a/usr.bin/ssh/servconf.c +++ b/usr.bin/ssh/servconf.c @@ -1,5 +1,4 @@ - -/* $OpenBSD: servconf.c,v 1.395 2023/06/21 05:10:26 djm Exp $ */ +/* $OpenBSD: servconf.c,v 1.396 2023/07/17 05:26:38 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved diff --git a/usr.bin/ssh/ssh-agent.1 b/usr.bin/ssh/ssh-agent.1 index b0bf65da8..0c8979498 100644 --- a/usr.bin/ssh/ssh-agent.1 +++ b/usr.bin/ssh/ssh-agent.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-agent.1,v 1.75 2022/10/07 06:00:58 jmc Exp $ +.\" $OpenBSD: ssh-agent.1,v 1.77 2023/07/20 05:43:39 jmc Exp $ .\" .\" Author: Tatu Ylonen .\" Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -34,7 +34,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: October 7 2022 $ +.Dd $Mdocdate: July 20 2023 $ .Dt SSH-AGENT 1 .Os .Sh NAME @@ -107,9 +107,27 @@ environment variable). .It Fl O Ar option Specify an option when starting .Nm . -Currently only one option is supported: +Currently two options are supported: +.Cm allow-remote-pkcs11 +and .Cm no-restrict-websafe . -This instructs +.Pp +The +.Cm allow-remote-pkcs11 +option allows clients of a forwarded +.Nm +to load PKCS#11 or FIDO provider libraries. +By default only local clients may perform this operation. +Note that signalling that a +.Nm +client remote is performed by +.Xr ssh 1 , +and use of other tools to forward access to the agent socket, may circumvent +this restriction. +.Pp +The +.Cm no-restrict-websafe +option instructs .Nm to permit signatures using FIDO keys that might be web authentication requests. diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index 72e9da865..0b2ee9712 100644 --- a/usr.bin/ssh/ssh-agent.c +++ b/usr.bin/ssh/ssh-agent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.298 2023/03/31 04:45:08 dtucker Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.300 2023/07/19 13:56:33 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -156,6 +156,12 @@ char socket_dir[PATH_MAX]; /* Pattern-list of allowed PKCS#11/Security key paths */ static char *allowed_providers; +/* + * Allows PKCS11 providers or SK keys that use non-internal providers to + * be added over a remote connection (identified by session-bind@openssh.com). + */ +static int remote_add_provider; + /* locking */ #define LOCK_SIZE 32 #define LOCK_SALT_SIZE 16 @@ -830,8 +836,8 @@ process_sign_request2(SocketEntry *e) } /* Success */ ok = 0; - send: debug_f("good signature"); + send: notify_complete(notifier, "User presence confirmed"); if (ok == 0) { @@ -1215,6 +1221,12 @@ process_add_identity(SocketEntry *e) if (strcasecmp(sk_provider, "internal") == 0) { debug_f("internal provider"); } else { + if (e->nsession_ids != 0 && !remote_add_provider) { + verbose("failed add of SK provider \"%.100s\": " + "remote addition of providers is disabled", + sk_provider); + goto out; + } if (realpath(sk_provider, canonical_provider) == NULL) { verbose("failed provider \"%.100s\": " "realpath: %s", sk_provider, @@ -1378,6 +1390,11 @@ process_add_smartcard_key(SocketEntry *e) error_f("failed to parse constraints"); goto send; } + if (e->nsession_ids != 0 && !remote_add_provider) { + verbose("failed PKCS#11 add of \"%.100s\": remote addition of " + "providers is disabled", provider); + goto send; + } if (realpath(provider, canonical_provider) == NULL) { verbose("failed PKCS#11 add of \"%.100s\": realpath: %s", provider, strerror(errno)); @@ -2032,7 +2049,9 @@ main(int ac, char **av) break; case 'O': if (strcmp(optarg, "no-restrict-websafe") == 0) - restrict_websafe = 0; + restrict_websafe = 0; + else if (strcmp(optarg, "allow-remote-pkcs11") == 0) + remote_add_provider = 1; else fatal("Unknown -O option"); break; diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c index 7979930aa..7d7a78c54 100644 --- a/usr.bin/ssh/ssh-keygen.c +++ b/usr.bin/ssh/ssh-keygen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keygen.c,v 1.468 2023/06/20 00:05:09 djm Exp $ */ +/* $OpenBSD: ssh-keygen.c,v 1.470 2023/07/17 04:01:10 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1994 Tatu Ylonen , Espoo, Finland @@ -2200,7 +2200,7 @@ load_krl(const char *path, struct ssh_krl **krlp) if ((r = sshbuf_load_file(path, &krlbuf)) != 0) fatal_r(r, "Unable to load KRL %s", path); /* XXX check sigs */ - if ((r = ssh_krl_from_blob(krlbuf, krlp, NULL, 0)) != 0 || + if ((r = ssh_krl_from_blob(krlbuf, krlp)) != 0 || *krlp == NULL) fatal_r(r, "Invalid KRL file %s", path); sshbuf_free(krlbuf); @@ -2223,7 +2223,8 @@ hash_to_blob(const char *cp, u_char **blobp, size_t *lenp, * OpenSSH base64 hashes omit trailing '=' * characters; put them back for decode. */ - tlen = strlen(cp); + if ((tlen = strlen(cp)) >= SIZE_MAX - 5) + fatal_f("hash too long: %zu bytes", tlen); tmp = xmalloc(tlen + 4 + 1); strlcpy(tmp, cp, tlen + 1); while ((tlen % 4) != 0) { @@ -2265,6 +2266,10 @@ update_krl_from_file(struct passwd *pw, const char *file, int wild_ca, if (!quiet) printf("Revoking from %s\n", path); while (getline(&line, &linesize, krl_spec) != -1) { + if (linesize >= INT_MAX) { + fatal_f("%s contains unparsable line, len=%zu", + path, linesize); + } lnum++; was_explicit_key = was_sha1 = was_sha256 = was_hash = 0; cp = line + strspn(line, " \t"); @@ -2438,7 +2443,7 @@ do_gen_krl(struct passwd *pw, int updating, const char *ca_key_path, if ((kbuf = sshbuf_new()) == NULL) fatal("sshbuf_new failed"); - if (ssh_krl_to_blob(krl, kbuf, NULL, 0) != 0) + if (ssh_krl_to_blob(krl, kbuf) != 0) fatal("Couldn't generate KRL"); if ((r = sshbuf_write_file(identity_file, kbuf)) != 0) fatal("write %s: %s", identity_file, strerror(errno)); diff --git a/usr.bin/ssh/ssh-pkcs11-client.c b/usr.bin/ssh/ssh-pkcs11-client.c index a230abe30..d4221644c 100644 --- a/usr.bin/ssh/ssh-pkcs11-client.c +++ b/usr.bin/ssh/ssh-pkcs11-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-pkcs11-client.c,v 1.17 2020/10/18 11:32:02 djm Exp $ */ +/* $OpenBSD: ssh-pkcs11-client.c,v 1.18 2023/07/19 14:03:45 djm Exp $ */ /* * Copyright (c) 2010 Markus Friedl. All rights reserved. * Copyright (c) 2014 Pedro Martelletto. All rights reserved. @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -41,16 +42,136 @@ /* borrows code from sftp-server and ssh-agent */ -static int fd = -1; -static pid_t pid = -1; +/* + * Maintain a list of ssh-pkcs11-helper subprocesses. These may be looked up + * by provider path or their unique EC/RSA METHOD pointers. + */ +struct helper { + char *path; + pid_t pid; + int fd; + RSA_METHOD *rsa_meth; + EC_KEY_METHOD *ec_meth; + int (*rsa_finish)(RSA *rsa); + void (*ec_finish)(EC_KEY *key); + size_t nrsa, nec; /* number of active keys of each type */ +}; +static struct helper **helpers; +static size_t nhelpers; + +static struct helper * +helper_by_provider(const char *path) +{ + size_t i; + + for (i = 0; i < nhelpers; i++) { + if (helpers[i] == NULL || helpers[i]->path == NULL || + helpers[i]->fd == -1) + continue; + if (strcmp(helpers[i]->path, path) == 0) + return helpers[i]; + } + return NULL; +} + +static struct helper * +helper_by_rsa(const RSA *rsa) +{ + size_t i; + const RSA_METHOD *meth; + + if ((meth = RSA_get_method(rsa)) == NULL) + return NULL; + for (i = 0; i < nhelpers; i++) { + if (helpers[i] != NULL && helpers[i]->rsa_meth == meth) + return helpers[i]; + } + return NULL; + +} + +static struct helper * +helper_by_ec(const EC_KEY *ec) +{ + size_t i; + const EC_KEY_METHOD *meth; + + if ((meth = EC_KEY_get_method(ec)) == NULL) + return NULL; + for (i = 0; i < nhelpers; i++) { + if (helpers[i] != NULL && helpers[i]->ec_meth == meth) + return helpers[i]; + } + return NULL; + +} static void -send_msg(struct sshbuf *m) +helper_free(struct helper *helper) +{ + size_t i; + int found = 0; + + if (helper == NULL) + return; + if (helper->path == NULL || helper->ec_meth == NULL || + helper->rsa_meth == NULL) + fatal_f("inconsistent helper"); + debug3_f("free helper for provider %s", helper->path); + for (i = 0; i < nhelpers; i++) { + if (helpers[i] == helper) { + if (found) + fatal_f("helper recorded more than once"); + found = 1; + } + else if (found) + helpers[i - 1] = helpers[i]; + } + if (found) { + helpers = xrecallocarray(helpers, nhelpers, + nhelpers - 1, sizeof(*helpers)); + nhelpers--; + } + free(helper->path); + EC_KEY_METHOD_free(helper->ec_meth); + RSA_meth_free(helper->rsa_meth); + free(helper); +} + +static void +helper_terminate(struct helper *helper) +{ + if (helper == NULL) { + return; + } else if (helper->fd == -1) { + debug3_f("already terminated"); + } else { + debug3_f("terminating helper for %s; " + "remaining %zu RSA %zu ECDSA", + helper->path, helper->nrsa, helper->nec); + close(helper->fd); + /* XXX waitpid() */ + helper->fd = -1; + helper->pid = -1; + } + /* + * Don't delete the helper entry until there are no remaining keys + * that reference it. Otherwise, any signing operation would call + * a free'd METHOD pointer and that would be bad. + */ + if (helper->nrsa == 0 && helper->nec == 0) + helper_free(helper); +} + +static void +send_msg(int fd, struct sshbuf *m) { u_char buf[4]; size_t mlen = sshbuf_len(m); int r; + if (fd == -1) + return; POKE_U32(buf, mlen); if (atomicio(vwrite, fd, buf, 4) != 4 || atomicio(vwrite, fd, sshbuf_mutable_ptr(m), @@ -61,12 +182,15 @@ send_msg(struct sshbuf *m) } static int -recv_msg(struct sshbuf *m) +recv_msg(int fd, struct sshbuf *m) { u_int l, len; u_char c, buf[1024]; int r; + sshbuf_reset(m); + if (fd == -1) + return 0; /* XXX */ if ((len = atomicio(read, fd, buf, 4)) != 4) { error("read from helper failed: %u", len); return (0); /* XXX */ @@ -75,7 +199,6 @@ recv_msg(struct sshbuf *m) if (len > 256 * 1024) fatal("response too long: %u", len); /* read len bytes into m */ - sshbuf_reset(m); while (len > 0) { l = len; if (l > sizeof(buf)) @@ -96,14 +219,17 @@ recv_msg(struct sshbuf *m) int pkcs11_init(int interactive) { - return (0); + return 0; } void pkcs11_terminate(void) { - if (fd >= 0) - close(fd); + size_t i; + + debug3_f("terminating %zu helpers", nhelpers); + for (i = 0; i < nhelpers; i++) + helper_terminate(helpers[i]); } static int @@ -114,7 +240,11 @@ rsa_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa, int padding) u_char *blob = NULL, *signature = NULL; size_t blen, slen = 0; int r, ret = -1; + struct helper *helper; + if ((helper = helper_by_rsa(rsa)) == NULL || helper->fd == -1) + fatal_f("no helper for PKCS11 key"); + debug3_f("signing with PKCS11 provider %s", helper->path); if (padding != RSA_PKCS1_PADDING) goto fail; key = sshkey_new(KEY_UNSPEC); @@ -136,10 +266,10 @@ rsa_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa, int padding) (r = sshbuf_put_string(msg, from, flen)) != 0 || (r = sshbuf_put_u32(msg, 0)) != 0) fatal_fr(r, "compose"); - send_msg(msg); + send_msg(helper->fd, msg); sshbuf_reset(msg); - if (recv_msg(msg) == SSH2_AGENT_SIGN_RESPONSE) { + if (recv_msg(helper->fd, msg) == SSH2_AGENT_SIGN_RESPONSE) { if ((r = sshbuf_get_string(msg, &signature, &slen)) != 0) fatal_fr(r, "parse"); if (slen <= (size_t)RSA_size(rsa)) { @@ -155,6 +285,26 @@ rsa_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa, int padding) return (ret); } +static int +rsa_finish(RSA *rsa) +{ + struct helper *helper; + + if ((helper = helper_by_rsa(rsa)) == NULL) + fatal_f("no helper for PKCS11 key"); + debug3_f("free PKCS11 RSA key for provider %s", helper->path); + if (helper->rsa_finish != NULL) + helper->rsa_finish(rsa); + if (helper->nrsa == 0) + fatal_f("RSA refcount error"); + helper->nrsa--; + debug3_f("provider %s remaining keys: %zu RSA %zu ECDSA", + helper->path, helper->nrsa, helper->nec); + if (helper->nrsa == 0 && helper->nec == 0) + helper_terminate(helper); + return 1; +} + static ECDSA_SIG * ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, const BIGNUM *rp, EC_KEY *ec) @@ -166,7 +316,11 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, u_char *blob = NULL, *signature = NULL; size_t blen, slen = 0; int r, nid; + struct helper *helper; + if ((helper = helper_by_ec(ec)) == NULL || helper->fd == -1) + fatal_f("no helper for PKCS11 key"); + debug3_f("signing with PKCS11 provider %s", helper->path); nid = sshkey_ecdsa_key_to_nid(ec); if (nid < 0) { error_f("couldn't get curve nid"); @@ -194,10 +348,10 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, (r = sshbuf_put_string(msg, dgst, dgst_len)) != 0 || (r = sshbuf_put_u32(msg, 0)) != 0) fatal_fr(r, "compose"); - send_msg(msg); + send_msg(helper->fd, msg); sshbuf_reset(msg); - if (recv_msg(msg) == SSH2_AGENT_SIGN_RESPONSE) { + if (recv_msg(helper->fd, msg) == SSH2_AGENT_SIGN_RESPONSE) { if ((r = sshbuf_get_string(msg, &signature, &slen)) != 0) fatal_fr(r, "parse"); cp = signature; @@ -212,67 +366,109 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, return (ret); } -static RSA_METHOD *helper_rsa; -static EC_KEY_METHOD *helper_ecdsa; +static void +ecdsa_do_finish(EC_KEY *ec) +{ + struct helper *helper; + + if ((helper = helper_by_ec(ec)) == NULL) + fatal_f("no helper for PKCS11 key"); + debug3_f("free PKCS11 ECDSA key for provider %s", helper->path); + if (helper->ec_finish != NULL) + helper->ec_finish(ec); + if (helper->nec == 0) + fatal_f("ECDSA refcount error"); + helper->nec--; + debug3_f("provider %s remaining keys: %zu RSA %zu ECDSA", + helper->path, helper->nrsa, helper->nec); + if (helper->nrsa == 0 && helper->nec == 0) + helper_terminate(helper); +} /* redirect private key crypto operations to the ssh-pkcs11-helper */ static void -wrap_key(struct sshkey *k) +wrap_key(struct helper *helper, struct sshkey *k) { - if (k->type == KEY_RSA) - RSA_set_method(k->rsa, helper_rsa); - else if (k->type == KEY_ECDSA) - EC_KEY_set_method(k->ecdsa, helper_ecdsa); - else + debug3_f("wrap %s for provider %s", sshkey_type(k), helper->path); + if (k->type == KEY_RSA) { + RSA_set_method(k->rsa, helper->rsa_meth); + if (helper->nrsa++ >= INT_MAX) + fatal_f("RSA refcount error"); + } else if (k->type == KEY_ECDSA) { + EC_KEY_set_method(k->ecdsa, helper->ec_meth); + if (helper->nec++ >= INT_MAX) + fatal_f("EC refcount error"); + } else fatal_f("unknown key type"); + k->flags |= SSHKEY_FLAG_EXT; + debug3_f("provider %s remaining keys: %zu RSA %zu ECDSA", + helper->path, helper->nrsa, helper->nec); } static int -pkcs11_start_helper_methods(void) +pkcs11_start_helper_methods(struct helper *helper) { - if (helper_ecdsa != NULL) - return (0); - - int (*orig_sign)(int, const unsigned char *, int, unsigned char *, + int (*ec_init)(EC_KEY *key); + int (*ec_copy)(EC_KEY *dest, const EC_KEY *src); + int (*ec_set_group)(EC_KEY *key, const EC_GROUP *grp); + int (*ec_set_private)(EC_KEY *key, const BIGNUM *priv_key); + int (*ec_set_public)(EC_KEY *key, const EC_POINT *pub_key); + int (*ec_sign)(int, const unsigned char *, int, unsigned char *, unsigned int *, const BIGNUM *, const BIGNUM *, EC_KEY *) = NULL; - if (helper_ecdsa != NULL) - return (0); - helper_ecdsa = EC_KEY_METHOD_new(EC_KEY_OpenSSL()); - if (helper_ecdsa == NULL) - return (-1); - EC_KEY_METHOD_get_sign(helper_ecdsa, &orig_sign, NULL, NULL); - EC_KEY_METHOD_set_sign(helper_ecdsa, orig_sign, NULL, ecdsa_do_sign); + RSA_METHOD *rsa_meth; + EC_KEY_METHOD *ec_meth; - if ((helper_rsa = RSA_meth_dup(RSA_get_default_method())) == NULL) + if ((ec_meth = EC_KEY_METHOD_new(EC_KEY_OpenSSL())) == NULL) + return -1; + EC_KEY_METHOD_get_sign(ec_meth, &ec_sign, NULL, NULL); + EC_KEY_METHOD_set_sign(ec_meth, ec_sign, NULL, ecdsa_do_sign); + EC_KEY_METHOD_get_init(ec_meth, &ec_init, &helper->ec_finish, + &ec_copy, &ec_set_group, &ec_set_private, &ec_set_public); + EC_KEY_METHOD_set_init(ec_meth, ec_init, ecdsa_do_finish, + ec_copy, ec_set_group, ec_set_private, ec_set_public); + + if ((rsa_meth = RSA_meth_dup(RSA_get_default_method())) == NULL) fatal_f("RSA_meth_dup failed"); - if (!RSA_meth_set1_name(helper_rsa, "ssh-pkcs11-helper") || - !RSA_meth_set_priv_enc(helper_rsa, rsa_encrypt)) + helper->rsa_finish = RSA_meth_get_finish(rsa_meth); + if (!RSA_meth_set1_name(rsa_meth, "ssh-pkcs11-helper") || + !RSA_meth_set_priv_enc(rsa_meth, rsa_encrypt) || + !RSA_meth_set_finish(rsa_meth, rsa_finish)) fatal_f("failed to prepare method"); - return (0); + helper->ec_meth = ec_meth; + helper->rsa_meth = rsa_meth; + return 0; } -static int -pkcs11_start_helper(void) +static struct helper * +pkcs11_start_helper(const char *path) { int pair[2]; - char *helper, *verbosity = NULL; - - if (log_level_get() >= SYSLOG_LEVEL_DEBUG1) - verbosity = "-vvv"; - - if (pkcs11_start_helper_methods() == -1) { - error("pkcs11_start_helper_methods failed"); - return (-1); - } + char *prog, *verbosity = NULL; + struct helper *helper; + pid_t pid; + if (nhelpers >= INT_MAX) + fatal_f("too many helpers"); + debug3_f("start helper for %s", path); if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) { - error("socketpair: %s", strerror(errno)); - return (-1); + error_f("socketpair: %s", strerror(errno)); + return NULL; + } + helper = xcalloc(1, sizeof(*helper)); + if (pkcs11_start_helper_methods(helper) == -1) { + error_f("pkcs11_start_helper_methods failed"); + goto fail; } if ((pid = fork()) == -1) { - error("fork: %s", strerror(errno)); - return (-1); + error_f("fork: %s", strerror(errno)); + fail: + close(pair[0]); + close(pair[1]); + RSA_meth_free(helper->rsa_meth); + EC_KEY_METHOD_free(helper->ec_meth); + free(helper); + return NULL; } else if (pid == 0) { if ((dup2(pair[1], STDIN_FILENO) == -1) || (dup2(pair[1], STDOUT_FILENO) == -1)) { @@ -281,18 +477,27 @@ pkcs11_start_helper(void) } close(pair[0]); close(pair[1]); - helper = getenv("SSH_PKCS11_HELPER"); - if (helper == NULL || strlen(helper) == 0) - helper = _PATH_SSH_PKCS11_HELPER; - debug_f("starting %s %s", helper, + prog = getenv("SSH_PKCS11_HELPER"); + if (prog == NULL || strlen(prog) == 0) + prog = _PATH_SSH_PKCS11_HELPER; + if (log_level_get() >= SYSLOG_LEVEL_DEBUG1) + verbosity = "-vvv"; + debug_f("starting %s %s", prog, verbosity == NULL ? "" : verbosity); - execlp(helper, helper, verbosity, (char *)NULL); - fprintf(stderr, "exec: %s: %s\n", helper, strerror(errno)); + execlp(prog, prog, verbosity, (char *)NULL); + fprintf(stderr, "exec: %s: %s\n", prog, strerror(errno)); _exit(1); } close(pair[1]); - fd = pair[0]; - return (0); + helper->fd = pair[0]; + helper->path = xstrdup(path); + helper->pid = pid; + debug3_f("helper %zu for \"%s\" on fd %d pid %ld", nhelpers, + helper->path, helper->fd, (long)helper->pid); + helpers = xrecallocarray(helpers, nhelpers, + nhelpers + 1, sizeof(*helpers)); + helpers[nhelpers++] = helper; + return helper; } int @@ -306,9 +511,11 @@ pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp, size_t blen; u_int nkeys, i; struct sshbuf *msg; + struct helper *helper; - if (fd < 0 && pkcs11_start_helper() < 0) - return (-1); + if ((helper = helper_by_provider(name)) == NULL && + (helper = pkcs11_start_helper(name)) == NULL) + return -1; if ((msg = sshbuf_new()) == NULL) fatal_f("sshbuf_new failed"); @@ -316,10 +523,10 @@ pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp, (r = sshbuf_put_cstring(msg, name)) != 0 || (r = sshbuf_put_cstring(msg, pin)) != 0) fatal_fr(r, "compose"); - send_msg(msg); + send_msg(helper->fd, msg); sshbuf_reset(msg); - type = recv_msg(msg); + type = recv_msg(helper->fd, msg); if (type == SSH2_AGENT_IDENTITIES_ANSWER) { if ((r = sshbuf_get_u32(msg, &nkeys)) != 0) fatal_fr(r, "parse nkeys"); @@ -333,7 +540,7 @@ pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp, fatal_fr(r, "parse key"); if ((r = sshkey_from_blob(blob, blen, &k)) != 0) fatal_fr(r, "decode key"); - wrap_key(k); + wrap_key(helper, k); (*keysp)[i] = k; if (labelsp) (*labelsp)[i] = label; @@ -354,20 +561,14 @@ pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp, int pkcs11_del_provider(char *name) { - int r, ret = -1; - struct sshbuf *msg; + struct helper *helper; - if ((msg = sshbuf_new()) == NULL) - fatal_f("sshbuf_new failed"); - if ((r = sshbuf_put_u8(msg, SSH_AGENTC_REMOVE_SMARTCARD_KEY)) != 0 || - (r = sshbuf_put_cstring(msg, name)) != 0 || - (r = sshbuf_put_cstring(msg, "")) != 0) - fatal_fr(r, "compose"); - send_msg(msg); - sshbuf_reset(msg); - - if (recv_msg(msg) == SSH_AGENT_SUCCESS) - ret = 0; - sshbuf_free(msg); - return (ret); + /* + * ssh-agent deletes keys before calling this, so the helper entry + * should be gone before we get here. + */ + debug3_f("delete %s", name); + if ((helper = helper_by_provider(name)) != NULL) + helper_terminate(helper); + return 0; } diff --git a/usr.bin/ssh/ssh-pkcs11.c b/usr.bin/ssh/ssh-pkcs11.c index 3d9a92f77..e9aada6b8 100644 --- a/usr.bin/ssh/ssh-pkcs11.c +++ b/usr.bin/ssh/ssh-pkcs11.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-pkcs11.c,v 1.56 2023/03/08 05:33:53 tb Exp $ */ +/* $OpenBSD: ssh-pkcs11.c,v 1.58 2023/07/19 14:02:27 djm Exp $ */ /* * Copyright (c) 2010 Markus Friedl. All rights reserved. * Copyright (c) 2014 Pedro Martelletto. All rights reserved. @@ -1507,15 +1507,17 @@ pkcs11_register_provider(char *provider_id, char *pin, debug_f("provider already registered: %s", provider_id); goto fail; } + if (lib_contains_symbol(provider_id, "C_GetFunctionList") != 0) { + error("provider %s is not a PKCS11 library", provider_id); + goto fail; + } /* open shared pkcs11-library */ if ((handle = dlopen(provider_id, RTLD_NOW)) == NULL) { error("dlopen %s failed: %s", provider_id, dlerror()); goto fail; } - if ((getfunctionlist = dlsym(handle, "C_GetFunctionList")) == NULL) { - error("dlsym(C_GetFunctionList) failed: %s", dlerror()); - goto fail; - } + if ((getfunctionlist = dlsym(handle, "C_GetFunctionList")) == NULL) + fatal("dlsym(C_GetFunctionList) failed: %s", dlerror()); p = xcalloc(1, sizeof(*p)); p->name = xstrdup(provider_id); p->handle = handle; diff --git a/usr.bin/ssh/ssh-sk.c b/usr.bin/ssh/ssh-sk.c index e5e72f278..d6eea2e05 100644 --- a/usr.bin/ssh/ssh-sk.c +++ b/usr.bin/ssh/ssh-sk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-sk.c,v 1.39 2022/07/20 03:29:14 djm Exp $ */ +/* $OpenBSD: ssh-sk.c,v 1.40 2023/07/19 14:02:27 djm Exp $ */ /* * Copyright (c) 2019 Google LLC * @@ -113,15 +113,18 @@ sshsk_open(const char *path) ret->sk_load_resident_keys = ssh_sk_load_resident_keys; return ret; } + if (lib_contains_symbol(path, "sk_api_version") != 0) { + error("provider %s is not an OpenSSH FIDO library", path); + goto fail; + } if ((ret->dlhandle = dlopen(path, RTLD_NOW)) == NULL) { error("Provider \"%s\" dlopen failed: %s", path, dlerror()); goto fail; } if ((ret->sk_api_version = dlsym(ret->dlhandle, "sk_api_version")) == NULL) { - error("Provider \"%s\" dlsym(sk_api_version) failed: %s", + fatal("Provider \"%s\" dlsym(sk_api_version) failed: %s", path, dlerror()); - goto fail; } version = ret->sk_api_version(); debug_f("provider %s implements version 0x%08lx", ret->path, diff --git a/usr.bin/ssh/ssh.1 b/usr.bin/ssh/ssh.1 index 3d89c7d7f..0a65f57bb 100644 --- a/usr.bin/ssh/ssh.1 +++ b/usr.bin/ssh/ssh.1 @@ -33,8 +33,8 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: ssh.1,v 1.434 2023/06/21 05:08:32 djm Exp $ -.Dd $Mdocdate: June 21 2023 $ +.\" $OpenBSD: ssh.1,v 1.436 2023/07/17 05:38:10 jmc Exp $ +.Dd $Mdocdate: July 17 2023 $ .Dt SSH 1 .Os .Sh NAME @@ -58,6 +58,7 @@ .Op Fl m Ar mac_spec .Op Fl O Ar ctl_cmd .Op Fl o Ar option +.Op Fl P Ar tag .Op Fl p Ar port .Op Fl Q Ar query_option .Op Fl R Ar address @@ -593,6 +594,16 @@ For full details of the options listed below, and their possible values, see .It XAuthLocation .El .Pp +.It Fl P Ar tag +Specify a tag name that may be used to select configuration in +.Xr ssh_config 5 . +Refer to the +.Cm Tag +and +.Cm Match +keywords in +.Xr ssh_config 5 +for more information. .It Fl p Ar port Port to connect to on the remote host. This can be specified on a diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index 3f90b6dd9..448e99d58 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.590 2023/07/04 03:59:21 dlg Exp $ */ +/* $OpenBSD: ssh.c,v 1.592 2023/07/17 05:41:53 jmc Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -163,13 +163,13 @@ static void usage(void) { fprintf(stderr, -"usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]\n" -" [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]\n" -" [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]\n" -" [-i identity_file] [-J [user@]host[:port]] [-L address]\n" -" [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" -" [-Q query_option] [-R address] [-S ctl_path] [-W host:port]\n" -" [-w local_tun[:remote_tun]] destination [command [argument ...]]\n" +"usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]\n" +" [-c cipher_spec] [-D [bind_address:]port] [-E log_file]\n" +" [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]\n" +" [-J destination] [-L address] [-l login_name] [-m mac_spec]\n" +" [-O ctl_cmd] [-o option] [-P tag] [-p port] [-Q query_option]\n" +" [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]\n" +" destination [command [argument ...]]\n" ); exit(255); } @@ -682,7 +682,7 @@ main(int ac, char **av) again: while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" - "AB:CD:E:F:GI:J:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) { /* HUZdhjruz */ + "AB:CD:E:F:GI:J:KL:MNO:P:Q:R:S:TVw:W:XYy")) != -1) { /* HUZdhjruz */ switch (opt) { case '1': fatal("SSH protocol v.1 is no longer supported"); @@ -746,7 +746,9 @@ main(int ac, char **av) else fatal("Invalid multiplex command."); break; - case 'P': /* deprecated */ + case 'P': + if (options.tag == NULL) + options.tag = xstrdup(optarg); break; case 'Q': cp = NULL; diff --git a/usr.bin/ssh/ssh_config.5 b/usr.bin/ssh/ssh_config.5 index 972cafee6..1eae6e726 100644 --- a/usr.bin/ssh/ssh_config.5 +++ b/usr.bin/ssh/ssh_config.5 @@ -33,8 +33,8 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: ssh_config.5,v 1.380 2023/03/27 03:56:11 dtucker Exp $ -.Dd $Mdocdate: March 27 2023 $ +.\" $OpenBSD: ssh_config.5,v 1.383 2023/07/17 05:36:14 jsg Exp $ +.Dd $Mdocdate: July 17 2023 $ .Dt SSH_CONFIG 5 .Os .Sh NAME @@ -141,8 +141,10 @@ The available criteria keywords are: .Cm canonical , .Cm final , .Cm exec , +.Cm localnetwork , .Cm host , .Cm originalhost , +.Cm Tag , .Cm user , and .Cm localuser . @@ -195,6 +197,17 @@ accept the tokens described in the .Sx TOKENS section. .Pp +The +.Cm localnetwork +keyword matches the addresses of active local network interfaces against the +supplied list of networks in CIDR format. +This may be convenient for varying the effective configuration on devices that +roam between networks. +Note that network address is not a trustworthy criteria in many +situations (e.g. when the network is automatically configured using DHCP) +and so caution should be applied if using it to control security-sensitive +configuration. +.Pp The other keywords' criteria must be single entries or comma-separated lists and may use the wildcard and negation operators described in the .Sx PATTERNS @@ -211,6 +224,15 @@ The .Cm originalhost keyword matches against the hostname as it was specified on the command-line. The +.Cm tagged +keyword matches a tag name specified by a prior +.Cm Tag +directive or on the +.Xr ssh 1 +command-line using the +.Fl P +flag. +The .Cm user keyword matches against the target username on the remote host. The @@ -1875,6 +1897,10 @@ To disable TCP keepalive messages, the value should be set to See also .Cm ServerAliveInterval for protocol-level keepalives. +.It Cm Tag +Specify a configuration tag name that may be later used by a +.Cm Match +directive to select a block of configuration. .It Cm Tunnel Request .Xr tun 4 diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index b5c4d36db..f8195090c 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.159 2023/01/06 07:09:27 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.161 2023/07/10 12:00:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -246,9 +246,6 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags, u_int ncaps = 0; struct args_value *values; - /* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */ - signal(SIGCHLD, SIG_IGN); - /* Set up the initial command. */ if (shell_command != NULL) { msg = MSG_SHELL; @@ -526,11 +523,22 @@ client_signal(int sig) { struct sigaction sigact; int status; + pid_t pid; log_debug("%s: %s", __func__, strsignal(sig)); - if (sig == SIGCHLD) - waitpid(WAIT_ANY, &status, WNOHANG); - else if (!client_attached) { + if (sig == SIGCHLD) { + for (;;) { + pid = waitpid(WAIT_ANY, &status, WNOHANG); + if (pid == 0) + break; + if (pid == -1) { + if (errno == ECHILD) + break; + log_debug("waitpid failed: %s", + strerror(errno)); + } + } + } else if (!client_attached) { if (sig == SIGTERM || sig == SIGHUP) proc_exit(client_proc); } else { diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index e7cb49a1b..3353646b5 100644 --- a/usr.bin/tmux/cmd-find.c +++ b/usr.bin/tmux/cmd-find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find.c,v 1.82 2022/11/01 09:46:14 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.83 2023/07/10 09:24:53 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -583,7 +583,7 @@ cmd_find_get_pane_with_window(struct cmd_find_state *fs, const char *pane) /* Try special characters. */ if (strcmp(pane, "!") == 0) { - fs->wp = fs->w->last; + fs->wp = TAILQ_FIRST(&fs->w->last_panes); if (fs->wp == NULL) return (-1); return (0); diff --git a/usr.bin/tmux/cmd-select-pane.c b/usr.bin/tmux/cmd-select-pane.c index 62b48fd68..c067585c9 100644 --- a/usr.bin/tmux/cmd-select-pane.c +++ b/usr.bin/tmux/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-pane.c,v 1.68 2021/08/21 10:22:39 nicm Exp $ */ +/* $OpenBSD: cmd-select-pane.c,v 1.69 2023/07/10 09:24:53 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -98,7 +98,11 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) struct options_entry *o; if (entry == &cmd_last_pane_entry || args_has(args, 'l')) { - lastwp = w->last; + /* + * Check for no last pane found in case the other pane was + * spawned without being visited (for example split-window -d). + */ + lastwp = TAILQ_FIRST(&w->last_panes); if (lastwp == NULL && window_count_panes(w) == 2) { lastwp = TAILQ_PREV(w->active, window_panes, entry); if (lastwp == NULL) diff --git a/usr.bin/tmux/cmd-swap-pane.c b/usr.bin/tmux/cmd-swap-pane.c index 0cc451776..de8c6e7ab 100644 --- a/usr.bin/tmux/cmd-swap-pane.c +++ b/usr.bin/tmux/cmd-swap-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-swap-pane.c,v 1.42 2023/01/17 06:50:55 nicm Exp $ */ +/* $OpenBSD: cmd-swap-pane.c,v 1.43 2023/07/10 09:24:53 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -128,10 +128,8 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item) window_set_active_pane(dst_w, src_wp, 1); } if (src_w != dst_w) { - if (src_w->last == src_wp) - src_w->last = NULL; - if (dst_w->last == dst_wp) - dst_w->last = NULL; + window_pane_stack_remove(&src_w->last_panes, src_wp); + window_pane_stack_remove(&dst_w->last_panes, dst_wp); colour_palette_from_option(&src_wp->palette, src_wp->options); colour_palette_from_option(&dst_wp->palette, dst_wp->options); } diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index bf89cbebd..ff1293ed2 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.315 2023/07/03 10:48:26 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.316 2023/07/10 09:24:53 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -1902,7 +1902,7 @@ static void * format_cb_pane_last(struct format_tree *ft) { if (ft->wp != NULL) { - if (ft->wp == ft->wp->window->last) + if (ft->wp == TAILQ_FIRST(&ft->wp->window->last_panes)) return (xstrdup("1")); return (xstrdup("0")); } diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 17c9e7528..faf9dacfe 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.129 2023/06/30 21:55:08 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.130 2023/07/13 06:03:48 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -37,7 +37,7 @@ /* Default grid cell data. */ const struct grid_cell grid_default_cell = { - { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0, 0 + { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 8, 0 }; /* @@ -45,12 +45,12 @@ const struct grid_cell grid_default_cell = { * appears in the grid - because of this, they are always extended cells. */ static const struct grid_cell grid_padding_cell = { - { { '!' }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 0, 0 + { { '!' }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 8, 0 }; /* Cleared grid cell data. */ static const struct grid_cell grid_cleared_cell = { - { { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 0, 0 + { { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 8, 0 }; static const struct grid_cell_entry grid_cleared_entry = { { .data = { 0, 8, 8, ' ' } }, GRID_FLAG_CLEARED @@ -528,7 +528,7 @@ grid_get_cell1(struct grid_line *gl, u_int px, struct grid_cell *gc) gc->bg = gce->data.bg; if (gce->flags & GRID_FLAG_BG256) gc->bg |= COLOUR_FLAG_256; - gc->us = 0; + gc->us = 8; utf8_set(&gc->data, gce->data.data); gc->link = 0; } @@ -956,7 +956,7 @@ grid_string_cells_code(const struct grid_cell *lastgc, for (i = 0; i < nitems(attrs); i++) { if (((~attr & attrs[i].mask) && (lastattr & attrs[i].mask)) || - (lastgc->us != 0 && gc->us == 0)) { + (lastgc->us != 8 && gc->us == 8)) { s[n++] = 0; lastattr &= GRID_ATTR_CHARSET; break; diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index fcc9b260a..2157dac28 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.217 2023/07/03 16:47:43 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.218 2023/07/13 06:03:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2186,7 +2186,7 @@ input_csi_dispatch_sgr(struct input_ctx *ictx) gc->attr &= ~GRID_ATTR_OVERLINE; break; case 59: - gc->us = 0; + gc->us = 8; break; case 90: case 91: diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index c76adbe2d..43c923e68 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.214 2023/03/27 08:31:32 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.215 2023/07/14 19:32:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -326,7 +326,9 @@ screen_write_reset(struct screen_write_ctx *ctx) screen_reset_tabs(s); screen_write_scrollregion(ctx, 0, screen_size_y(s) - 1); - s->mode = MODE_CURSOR | MODE_WRAP; + s->mode = MODE_CURSOR|MODE_WRAP; + if (options_get_number(global_options, "extended-keys") == 2) + s->mode |= MODE_KEXTENDED; screen_write_clearscreen(ctx, 8); screen_write_set_cursor(ctx, 0, 0); diff --git a/usr.bin/tmux/session.c b/usr.bin/tmux/session.c index ade301177..84bcbf4d1 100644 --- a/usr.bin/tmux/session.c +++ b/usr.bin/tmux/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.93 2022/10/17 10:59:42 nicm Exp $ */ +/* $OpenBSD: session.c,v 1.94 2023/07/19 13:03:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -739,9 +739,12 @@ session_renumber_windows(struct session *s) memcpy(&old_lastw, &s->lastw, sizeof old_lastw); TAILQ_INIT(&s->lastw); TAILQ_FOREACH(wl, &old_lastw, sentry) { + wl->flags &= ~WINLINK_VISITED; wl_new = winlink_find_by_window(&s->windows, wl->window); - if (wl_new != NULL) + if (wl_new != NULL) { TAILQ_INSERT_TAIL(&s->lastw, wl_new, sentry); + wl_new->flags |= WINLINK_VISITED; + } } /* Set the current window. */ diff --git a/usr.bin/tmux/spawn.c b/usr.bin/tmux/spawn.c index 3e67eaee7..3147d1f05 100644 --- a/usr.bin/tmux/spawn.c +++ b/usr.bin/tmux/spawn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spawn.c,v 1.31 2022/08/10 14:03:59 nicm Exp $ */ +/* $OpenBSD: spawn.c,v 1.33 2023/07/10 09:24:53 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott @@ -115,6 +115,7 @@ spawn_window(struct spawn_context *sc, char **cause) window_pane_resize(sc->wp0, w->sx, w->sy); layout_init(w, sc->wp0); + w->active = NULL; window_set_active_pane(w, sc->wp0, 0); } @@ -415,8 +416,8 @@ spawn_pane(struct spawn_context *sc, char **cause) _exit(1); /* Clean up file descriptors and signals and update the environment. */ - closefrom(STDERR_FILENO + 1); proc_clear_signals(server_proc, 1); + closefrom(STDERR_FILENO + 1); sigprocmask(SIG_SETMASK, &oldset, NULL); log_close(); environ_push(child); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 0ce74092d..cf0f9fdb1 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.922 2023/07/03 16:47:43 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.924 2023/07/11 16:09:09 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 3 2023 $ +.Dd $Mdocdate: July 11 2023 $ .Dt TMUX 1 .Os .Sh NAME @@ -1742,93 +1742,266 @@ Key tables may be viewed with the command. .Pp The following commands are supported in copy mode: -.Bl -column "CommandXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "viXXXXXXXXXX" "emacs" -offset indent -.It Sy "Command" Ta Sy "vi" Ta Sy "emacs" -.It Li "append-selection" Ta "" Ta "" -.It Li "append-selection-and-cancel" Ta "A" Ta "" -.It Li "back-to-indentation" Ta "^" Ta "M-m" -.It Li "begin-selection" Ta "Space" Ta "C-Space" -.It Li "bottom-line" Ta "L" Ta "" -.It Li "cancel" Ta "q" Ta "Escape" -.It Li "clear-selection" Ta "Escape" Ta "C-g" -.It Li "copy-end-of-line []" Ta "" Ta "" -.It Li "copy-end-of-line-and-cancel []" Ta "" Ta "" -.It Li "copy-pipe-end-of-line [] []" Ta "" Ta "" -.It Li "copy-pipe-end-of-line-and-cancel [] []" Ta "D" Ta "C-k" -.It Li "copy-line []" Ta "" Ta "" -.It Li "copy-line-and-cancel []" Ta "" Ta "" -.It Li "copy-pipe-line [] []" Ta "" Ta "" -.It Li "copy-pipe-line-and-cancel [] []" Ta "" Ta "" -.It Li "copy-pipe [] []" Ta "" Ta "" -.It Li "copy-pipe-no-clear [] []" Ta "" Ta "" -.It Li "copy-pipe-and-cancel [] []" Ta "" Ta "" -.It Li "copy-selection []" Ta "" Ta "" -.It Li "copy-selection-no-clear []" Ta "" Ta "" -.It Li "copy-selection-and-cancel []" Ta "Enter" Ta "M-w" -.It Li "cursor-down" Ta "j" Ta "Down" -.It Li "cursor-down-and-cancel" Ta "" Ta "" -.It Li "cursor-left" Ta "h" Ta "Left" -.It Li "cursor-right" Ta "l" Ta "Right" -.It Li "cursor-up" Ta "k" Ta "Up" -.It Li "end-of-line" Ta "$" Ta "C-e" -.It Li "goto-line " Ta ":" Ta "g" -.It Li "halfpage-down" Ta "C-d" Ta "M-Down" -.It Li "halfpage-down-and-cancel" Ta "" Ta "" -.It Li "halfpage-up" Ta "C-u" Ta "M-Up" -.It Li "history-bottom" Ta "G" Ta "M->" -.It Li "history-top" Ta "g" Ta "M-<" -.It Li "jump-again" Ta ";" Ta ";" -.It Li "jump-backward " Ta "F" Ta "F" -.It Li "jump-forward " Ta "f" Ta "f" -.It Li "jump-reverse" Ta "," Ta "," -.It Li "jump-to-backward " Ta "T" Ta "" -.It Li "jump-to-forward " Ta "t" Ta "" -.It Li "jump-to-mark" Ta "M-x" Ta "M-x" -.It Li "middle-line" Ta "M" Ta "M-r" -.It Li "next-matching-bracket" Ta "%" Ta "M-C-f" -.It Li "next-paragraph" Ta "}" Ta "M-}" -.It Li "next-prompt" Ta "" Ta "" -.It Li "next-space" Ta "W" Ta "" -.It Li "next-space-end" Ta "E" Ta "" -.It Li "next-word" Ta "w" Ta "" -.It Li "next-word-end" Ta "e" Ta "M-f" -.It Li "other-end" Ta "o" Ta "" -.It Li "page-down" Ta "C-f" Ta "PageDown" -.It Li "page-down-and-cancel" Ta "" Ta "" -.It Li "page-up" Ta "C-b" Ta "PageUp" -.It Li "pipe [] []" Ta "" Ta "" -.It Li "pipe-no-clear [] []" Ta "" Ta "" -.It Li "pipe-and-cancel [] []" Ta "" Ta "" -.It Li "previous-matching-bracket" Ta "" Ta "M-C-b" -.It Li "previous-paragraph" Ta "{" Ta "M-{" -.It Li "previous-prompt" Ta "" Ta "" -.It Li "previous-space" Ta "B" Ta "" -.It Li "previous-word" Ta "b" Ta "M-b" -.It Li "rectangle-on" Ta "" Ta "" -.It Li "rectangle-off" Ta "" Ta "" -.It Li "rectangle-toggle" Ta "v" Ta "R" -.It Li "refresh-from-pane" Ta "r" Ta "r" -.It Li "scroll-down" Ta "C-e" Ta "C-Down" -.It Li "scroll-down-and-cancel" Ta "" Ta "" -.It Li "scroll-up" Ta "C-y" Ta "C-Up" -.It Li "search-again" Ta "n" Ta "n" -.It Li "search-backward " Ta "?" Ta "" -.It Li "search-backward-incremental " Ta "" Ta "C-r" -.It Li "search-backward-text " Ta "" Ta "" -.It Li "search-forward " Ta "/" Ta "" -.It Li "search-forward-incremental " Ta "" Ta "C-s" -.It Li "search-forward-text " Ta "" Ta "" -.It Li "scroll-bottom" Ta "" Ta "" -.It Li "scroll-middle" Ta "z" Ta "" -.It Li "scroll-top" Ta "" Ta "" -.It Li "search-reverse" Ta "N" Ta "N" -.It Li "select-line" Ta "V" Ta "" -.It Li "select-word" Ta "" Ta "" -.It Li "set-mark" Ta "X" Ta "X" -.It Li "start-of-line" Ta "0" Ta "C-a" -.It Li "stop-selection" Ta "" Ta "" -.It Li "toggle-position" Ta "P" Ta "P" -.It Li "top-line" Ta "H" Ta "M-R" +.Bl -tag -width Ds +.It Xo +.Ic append-selection +.Xc +Append the selection to the top paste buffer. +.It Xo +.Ic append-selection-and-cancel +(vi: A) +.Xc +Append the selection to the top paste buffer and exit copy mode. +.It Xo +.Ic back-to-indentation +(vi: ^) +(emacs: M-m) +.Xc +Move the cursor back to the indentation. +.It Xo +.Ic begin-selection +(vi: Space) +(emacs: C-Space) +.Xc +Begin selection. +.It Xo +.Ic bottom-line +(vi: L) +.Xc +Move to the bottom line. +.It Xo +.Ic cancel +(vi: q) +(emacs: Escape) +.Xc +Exit copy mode. +.It Xo +.Ic clear-selection +(vi: Escape) +(emacs: C-g) +.Xc +Clear the current selection. +.It Xo +.Ic copy-end-of-line [] +.Xc +Copy from the cursor position to the end of the line. +.Ar prefix +is used to name the new paste buffer. +.It Xo +.Ic copy-end-of-line-and-cancel [] +.Xc +Copy from the cursor position and exit copy mode. +.It Xo +.Ic copy-line [] +.Xc +Copy the entire line. +.It Xo +.Ic copy-line-and-cancel [] +.Xc +Copy the entire line and exit copy mode. +.It Xo +.Ic copy-selection [] +.Xc +Copies the current selection. +.It Xo +.Ic copy-selection-and-cancel [] +(vi: Enter) +(emacs: M-w) +.Xc +Copy the current selection and exit copy mode. +.It Xo +.Ic cursor-down +(vi: j) +(emacs: Down) +.Xc +Move the cursor down. +.It Xo +.Ic cursor-left +(vi: h) +(emacs: Left) +.Xc +Move the cursor left. +.It Xo +.Ic cursor-right +(vi: l) +(emacs: Right) +.Xc +Move the cursor right. +.It Xo +.Ic cursor-up +(vi: k) +(emacs: Up) +.Xc +Move the cursor up. +.It Xo +.Ic end-of-line +(vi: $) +(emacs: C-e) +.Xc +Move the cursor to the end of the line. +.It Xo +.Ic goto-line +(vi: :) +(emacs: g) +.Xc +Move the cursor to a specific line. +.It Xo +.Ic history-bottom +(vi: G) +(emacs: M->) +.Xc +Scroll to the bottom of the history. +.It Xo +.Ic history-top +(vi: g) +(emacs: M-<) +.Xc +Scroll to the top of the history. +.It Xo +.Ic jump-again +(vi: ;) +(emacs: ;) +.Xc +Repeat the last jump. +.It Xo +.Ic jump-backward +(vi: F) +(emacs: F) +.Xc +Jump backwards to the specified text. +.It Xo +.Ic jump-forward +(vi: f) +(emacs: f) +.Xc +Jump forward to the specified text. +.It Xo +.Ic jump-to-mark +(vi: M-x) +(emacs: M-x) +.Xc +Jump to the last mark. +.It Xo +.Ic middle-line +(vi: M) +(emacs: M-r) +.Xc +Move to the middle line. +.It Xo +.Ic next-matching-bracket +(vi: %) +(emacs: M-C-f) +.Xc +Move to the next matching bracket. +.It Xo +.Ic next-paragraph +(vi: }) +(emacs: M-}) +.Xc +Move to the next paragraph. +.It Xo +.Ic next-prompt +.Xc +Move to the next prompt. +.It Xo +.Ic next-word +(vi: w) +.Xc +Move to the next word. +.It Xo +.Ic page-down +(vi: C-f) +(emacs: PageDown) +.Xc +Scroll down by one page. +.It Xo +.Ic page-up +(vi: C-b) +(emacs: PageUp) +.Xc +Scroll up by one page. +.It Xo +.Ic previous-matching-bracket +(emacs: M-C-b) +.Xc +Move to the previous matching bracket. +.It Xo +.Ic previous-paragraph +(vi: {) +(emacs: M-{) +.Xc +Move to the previous paragraph. +.It Xo +.Ic previous-prompt +.Xc +Move to the previous prompt. +.It Xo +.Ic previous-word +(vi: b) +(emacs: M-b) +.Xc +Move to the previous word. +.It Xo +.Ic rectangle-toggle +(vi: v) +(emacs: R) +.Xc +Toggle rectangle selection mode. +.It Xo +.Ic refresh-from-pane +(vi: r) +(emacs: r) +.Xc +Refresh the content from the pane. +.It Xo +.Ic search-again +(vi: n) +(emacs: n) +.Xc +Repeat the last search. +.It Xo +.Ic search-backward +(vi: ?) +.Xc +Search backwards for the specified text. +.It Xo +.Ic search-forward +(vi: /) +.Xc +Search forward for the specified text. +.It Xo +.Ic select-line +(vi: V) +.Xc +Select the current line. +.It Xo +.Ic select-word +.Xc +Select the current word. +.It Xo +.Ic start-of-line +(vi: 0) +(emacs: C-a) +.Xc +Move the cursor to the start of the line. +.It Xo +.Ic top-line +(vi: H) +(emacs: M-R) +.Xc +Move to the top line. +.It Xo +.Ic next-prompt +(vi: C-n) +(emacs: C-n) +.Xc +Move to the next prompt. +.It Xo +.Ic previous-prompt +(vi: C-p) +(emacs: C-p) +.Xc +Move to the previous prompt. .El .Pp The search commands come in several varieties: diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index d7b502416..fae976b8c 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1200 2023/07/03 16:47:43 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1201 2023/07/10 09:24:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1038,7 +1038,7 @@ struct window_pane { #define PANE_REDRAW 0x1 #define PANE_DROP 0x2 #define PANE_FOCUSED 0x4 -/* 0x8 unused */ +#define PANE_VISITED 0x8 /* 0x10 unused */ /* 0x20 unused */ #define PANE_INPUTOFF 0x40 @@ -1093,7 +1093,8 @@ struct window_pane { int border_gc_set; struct grid_cell border_gc; - TAILQ_ENTRY(window_pane) entry; + TAILQ_ENTRY(window_pane) entry; /* link in list of all panes */ + TAILQ_ENTRY(window_pane) sentry; /* link in list of last visited */ RB_ENTRY(window_pane) tree_entry; }; TAILQ_HEAD(window_panes, window_pane); @@ -1114,7 +1115,7 @@ struct window { struct timeval activity_time; struct window_pane *active; - struct window_pane *last; + struct window_panes last_panes; struct window_panes panes; int lastlayout; @@ -1167,6 +1168,7 @@ struct winlink { #define WINLINK_ACTIVITY 0x2 #define WINLINK_SILENCE 0x4 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE) +#define WINLINK_VISITED 0x8 RB_ENTRY(winlink) entry; TAILQ_ENTRY(winlink) wentry; @@ -3041,6 +3043,10 @@ struct window_pane *window_pane_find_up(struct window_pane *); struct window_pane *window_pane_find_down(struct window_pane *); struct window_pane *window_pane_find_left(struct window_pane *); struct window_pane *window_pane_find_right(struct window_pane *); +void window_pane_stack_push(struct window_panes *, + struct window_pane *); +void window_pane_stack_remove(struct window_panes *, + struct window_pane *); void window_set_name(struct window *, const char *); void window_add_ref(struct window *, const char *); void window_remove_ref(struct window *, const char *); diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 5aef5decd..94b33ce68 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.431 2023/06/26 07:17:40 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.432 2023/07/13 06:03:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2815,9 +2815,10 @@ tty_check_us(__unused struct tty *tty, struct colour_palette *palette, } /* Underscore colour is set as RGB so convert. */ - gc->us = colour_force_rgb (gc->us); - if (gc->us == -1) + if ((c = colour_force_rgb (gc->us)) == -1) gc->us = 8; + else + gc->us = c; } static void @@ -2892,7 +2893,7 @@ tty_colours_us(struct tty *tty, const struct grid_cell *gc) u_char r, g, b; /* Clear underline colour. */ - if (gc->us == 0) { + if (COLOUR_DEFAULT(gc->us)) { tty_putcode(tty, TTYC_OL); goto save; } diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 5e02fc251..f2e7d3d8e 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.285 2023/03/27 08:47:57 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.286 2023/07/10 09:24:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -248,21 +248,15 @@ winlink_stack_push(struct winlink_stack *stack, struct winlink *wl) winlink_stack_remove(stack, wl); TAILQ_INSERT_HEAD(stack, wl, sentry); + wl->flags |= WINLINK_VISITED; } void winlink_stack_remove(struct winlink_stack *stack, struct winlink *wl) { - struct winlink *wl2; - - if (wl == NULL) - return; - - TAILQ_FOREACH(wl2, stack, sentry) { - if (wl2 == wl) { - TAILQ_REMOVE(stack, wl, sentry); - return; - } + if (wl != NULL && (wl->flags & WINLINK_VISITED)) { + TAILQ_REMOVE(stack, wl, sentry); + wl->flags &= ~WINLINK_VISITED; } } @@ -312,6 +306,7 @@ window_create(u_int sx, u_int sy, u_int xpixel, u_int ypixel) w->flags = 0; TAILQ_INIT(&w->panes); + TAILQ_INIT(&w->last_panes); w->active = NULL; w->lastlayout = -1; @@ -512,18 +507,23 @@ window_pane_update_focus(struct window_pane *wp) int window_set_active_pane(struct window *w, struct window_pane *wp, int notify) { + struct window_pane *lastwp; + log_debug("%s: pane %%%u", __func__, wp->id); if (wp == w->active) return (0); - w->last = w->active; + lastwp = w->active; + + window_pane_stack_remove(&w->last_panes, wp); + window_pane_stack_push(&w->last_panes, lastwp); w->active = wp; w->active->active_point = next_active_point++; w->active->flags |= PANE_CHANGED; if (options_get_number(global_options, "focus-events")) { - window_pane_update_focus(w->last); + window_pane_update_focus(lastwp); window_pane_update_focus(w->active); } @@ -746,21 +746,21 @@ window_lost_pane(struct window *w, struct window_pane *wp) if (wp == marked_pane.wp) server_clear_marked(); + window_pane_stack_remove(&w->last_panes, wp); if (wp == w->active) { - w->active = w->last; - w->last = NULL; + w->active = TAILQ_FIRST(&w->last_panes); if (w->active == NULL) { w->active = TAILQ_PREV(wp, window_panes, entry); if (w->active == NULL) w->active = TAILQ_NEXT(wp, entry); } if (w->active != NULL) { + window_pane_stack_remove(&w->last_panes, w->active); w->active->flags |= PANE_CHANGED; notify_window("window-pane-changed", w); window_update_focus(w); } - } else if (wp == w->last) - w->last = NULL; + } } void @@ -844,6 +844,11 @@ window_destroy_panes(struct window *w) { struct window_pane *wp; + while (!TAILQ_EMPTY(&w->last_panes)) { + wp = TAILQ_FIRST(&w->last_panes); + window_pane_stack_remove(&w->last_panes, wp); + } + while (!TAILQ_EMPTY(&w->panes)) { wp = TAILQ_FIRST(&w->panes); TAILQ_REMOVE(&w->panes, wp, entry); @@ -1478,6 +1483,25 @@ window_pane_find_right(struct window_pane *wp) return (best); } +void +window_pane_stack_push(struct window_panes *stack, struct window_pane *wp) +{ + if (wp != NULL) { + window_pane_stack_remove(stack, wp); + TAILQ_INSERT_HEAD(stack, wp, sentry); + wp->flags |= PANE_VISITED; + } +} + +void +window_pane_stack_remove(struct window_panes *stack, struct window_pane *wp) +{ + if (wp != NULL && (wp->flags & PANE_VISITED)) { + TAILQ_REMOVE(stack, wp, sentry); + wp->flags &= ~PANE_VISITED; + } +} + /* Clear alert flags for a winlink */ void winlink_clear_flags(struct winlink *wl) diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index fc516b8fd..585d5f4fb 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.110 2023/04/20 12:53:27 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.111 2023/07/20 11:10:03 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -393,14 +393,14 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers) p->conf.down = 1; strlcpy(p->conf.reason, neighbor->reason, - sizeof(neighbor->reason)); + sizeof(p->conf.reason)); session_stop(p, ERR_CEASE_ADMIN_DOWN); control_result(c, CTL_RES_OK); break; case IMSG_CTL_NEIGHBOR_CLEAR: strlcpy(p->conf.reason, neighbor->reason, - sizeof(neighbor->reason)); + sizeof(p->conf.reason)); p->IdleHoldTime = INTERVAL_IDLE_HOLD_INITIAL; p->errcnt = 0; diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index e0c94d1f2..c6ce7ff50 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.114 2023/04/19 09:03:00 claudio Exp $ */ +/* $OpenBSD: mrt.c,v 1.116 2023/07/14 10:30:53 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -34,55 +34,19 @@ #include "mrt.h" #include "log.h" -int mrt_attr_dump(struct ibuf *, struct rde_aspath *, struct rde_community *, - struct bgpd_addr *, int); -int mrt_dump_entry_mp(struct mrt *, struct prefix *, uint16_t, - struct rde_peer*); -int mrt_dump_entry(struct mrt *, struct prefix *, uint16_t, struct rde_peer*); -int mrt_dump_entry_v2(struct mrt *, struct rib_entry *, uint32_t); -int mrt_dump_peer(struct ibuf *, struct rde_peer *); -int mrt_dump_hdr_se(struct ibuf **, struct peer *, uint16_t, uint16_t, - uint32_t, int); -int mrt_dump_hdr_rde(struct ibuf **, uint16_t type, uint16_t, uint32_t); -int mrt_open(struct mrt *, time_t); - -#define DUMP_BYTE(x, b) \ - do { \ - u_char t = (b); \ - if (ibuf_add((x), &t, sizeof(t)) == -1) { \ - log_warn("mrt_dump1: ibuf_add error"); \ - goto fail; \ - } \ - } while (0) - -#define DUMP_SHORT(x, s) \ - do { \ - uint16_t t; \ - t = htons((s)); \ - if (ibuf_add((x), &t, sizeof(t)) == -1) { \ - log_warn("mrt_dump2: ibuf_add error"); \ - goto fail; \ - } \ - } while (0) - -#define DUMP_LONG(x, l) \ - do { \ - uint32_t t; \ - t = htonl((l)); \ - if (ibuf_add((x), &t, sizeof(t)) == -1) { \ - log_warn("mrt_dump3: ibuf_add error"); \ - goto fail; \ - } \ - } while (0) - -#define DUMP_NLONG(x, l) \ - do { \ - uint32_t t = (l); \ - if (ibuf_add((x), &t, sizeof(t)) == -1) { \ - log_warn("mrt_dump4: ibuf_add error"); \ - goto fail; \ - } \ - } while (0) +static int mrt_attr_dump(struct ibuf *, struct rde_aspath *, + struct rde_community *, struct bgpd_addr *, int); +static int mrt_dump_entry_mp(struct mrt *, struct prefix *, uint16_t, + struct rde_peer*); +static int mrt_dump_entry(struct mrt *, struct prefix *, uint16_t, + struct rde_peer*); +static int mrt_dump_entry_v2(struct mrt *, struct rib_entry *, uint32_t); +static int mrt_dump_peer(struct ibuf *, struct rde_peer *); +static int mrt_dump_hdr_se(struct ibuf **, struct peer *, uint16_t, + uint16_t, uint32_t, int); +static int mrt_dump_hdr_rde(struct ibuf **, uint16_t type, uint16_t, + uint32_t); +static int mrt_open(struct mrt *, time_t); #define RDEIDX 0 #define SEIDX 1 @@ -223,15 +187,17 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, uint16_t pkglen, if (mrt_dump_hdr_se(&buf, peer, MSG_PROTOCOL_BGP4MP_ET, subtype, pkglen, in) == -1) - return; + goto fail; - if (ibuf_add(buf, pkg, pkglen) == -1) { - log_warn("mrt_dump_bgp_msg: ibuf_add error"); - ibuf_free(buf); - return; - } + if (ibuf_add(buf, pkg, pkglen) == -1) + goto fail; ibuf_close(&mrt->wbuf, buf); + return; + +fail: + log_warn("%s: ibuf error", __func__); + ibuf_free(buf); } void @@ -246,19 +212,22 @@ mrt_dump_state(struct mrt *mrt, uint16_t old_state, uint16_t new_state, if (mrt_dump_hdr_se(&buf, peer, MSG_PROTOCOL_BGP4MP_ET, subtype, 2 * sizeof(short), 0) == -1) - return; + goto fail; - DUMP_SHORT(buf, old_state); - DUMP_SHORT(buf, new_state); + if (ibuf_add_n16(buf, old_state) == -1) + goto fail; + if (ibuf_add_n16(buf, new_state) == -1) + goto fail; ibuf_close(&mrt->wbuf, buf); return; fail: + log_warn("%s: ibuf error", __func__); ibuf_free(buf); } -int +static int mrt_attr_dump(struct ibuf *buf, struct rde_aspath *a, struct rde_community *c, struct bgpd_addr *nexthop, int v2) { @@ -309,7 +278,9 @@ mrt_attr_dump(struct ibuf *buf, struct rde_aspath *a, struct rde_community *c, return (-1); /* communities */ - if (community_writebuf(buf, c) == -1) + if (community_writebuf(c, ATTR_COMMUNITIES, 0, buf) == -1 || + community_writebuf(c, ATTR_EXT_COMMUNITIES, 0, buf) == -1 || + community_writebuf(c, ATTR_LARGE_COMMUNITIES, 0, buf) == -1) return (-1); /* dump all other path attributes without modification */ @@ -328,38 +299,46 @@ mrt_attr_dump(struct ibuf *buf, struct rde_aspath *a, struct rde_community *c, return (-1); if (!v2) { if (aid2afi(nexthop->aid, &afi, &safi)) - return (-1); - DUMP_SHORT(nhbuf, afi); - DUMP_BYTE(nhbuf, safi); + goto fail; + if (ibuf_add_n16(nhbuf, afi) == -1) + goto fail; + if (ibuf_add_n8(nhbuf, safi) == -1) + goto fail; } switch (nexthop->aid) { case AID_INET6: - DUMP_BYTE(nhbuf, sizeof(struct in6_addr)); + if (ibuf_add_n8(nhbuf, sizeof(struct in6_addr)) == -1) + goto fail; if (ibuf_add(nhbuf, &nexthop->v6, sizeof(struct in6_addr)) == -1) goto fail; break; case AID_VPN_IPv4: - DUMP_BYTE(nhbuf, sizeof(uint64_t) + - sizeof(struct in_addr)); - DUMP_NLONG(nhbuf, 0); /* set RD to 0 */ - DUMP_NLONG(nhbuf, 0); - DUMP_NLONG(nhbuf, nexthop->v4.s_addr); + if (ibuf_add_n8(nhbuf, sizeof(uint64_t) + + sizeof(struct in_addr)) == -1) + goto fail; + if (ibuf_add_n64(nhbuf, 0) == -1) /* set RD to 0 */ + goto fail; + if (ibuf_add(nhbuf, &nexthop->v4, + sizeof(nexthop->v4)) == -1) + goto fail; break; case AID_VPN_IPv6: - DUMP_BYTE(nhbuf, sizeof(uint64_t) + - sizeof(struct in6_addr)); - DUMP_NLONG(nhbuf, 0); /* set RD to 0 */ - DUMP_NLONG(nhbuf, 0); - if (ibuf_add(nhbuf, &nexthop->v6, + if (ibuf_add_n8(nhbuf, sizeof(uint64_t) + sizeof(struct in6_addr)) == -1) goto fail; + if (ibuf_add_n64(nhbuf, 0) == -1) /* set RD to 0 */ + goto fail; + if (ibuf_add(nhbuf, &nexthop->v6, + sizeof(nexthop->v6)) == -1) + goto fail; break; } if (!v2) - DUMP_BYTE(nhbuf, 0); + if (ibuf_add_n8(nhbuf, 0) == -1) + goto fail; if (attr_writebuf(buf, ATTR_OPTIONAL, ATTR_MP_REACH_NLRI, - nhbuf->buf, ibuf_size(nhbuf)) == -1) { + ibuf_data(nhbuf), ibuf_size(nhbuf)) == -1) { fail: ibuf_free(nhbuf); return (-1); @@ -381,7 +360,7 @@ fail: return (0); } -int +static int mrt_dump_entry_mp(struct mrt *mrt, struct prefix *p, uint16_t snum, struct rde_peer *peer) { @@ -397,22 +376,21 @@ mrt_dump_entry_mp(struct mrt *mrt, struct prefix *p, uint16_t snum, } if (mrt_attr_dump(buf, prefix_aspath(p), prefix_communities(p), - NULL, 0) == -1) { - log_warnx("mrt_dump_entry_mp: mrt_attr_dump error"); + NULL, 0) == -1) goto fail; - } len = ibuf_size(buf); if ((h2buf = ibuf_dynamic(MRT_BGP4MP_IPv4_HEADER_SIZE + MRT_BGP4MP_IPv4_ENTRY_SIZE, MRT_BGP4MP_IPv6_HEADER_SIZE + - MRT_BGP4MP_IPv6_ENTRY_SIZE + MRT_BGP4MP_MAX_PREFIXLEN)) == NULL) { - log_warn("mrt_dump_entry_mp: ibuf_dynamic"); + MRT_BGP4MP_IPv6_ENTRY_SIZE + MRT_BGP4MP_MAX_PREFIXLEN)) == NULL) goto fail; - } - DUMP_SHORT(h2buf, peer->conf.local_short_as); - DUMP_SHORT(h2buf, peer->short_as); - DUMP_SHORT(h2buf, /* ifindex */ 0); + if (ibuf_add_n16(h2buf, peer->conf.local_short_as) == -1) + goto fail; + if (ibuf_add_n16(h2buf, peer->short_as) == -1) + goto fail; + if (ibuf_add_n16(h2buf, /* ifindex */ 0) == -1) + goto fail; /* XXX is this for peer self? */ aid = peer->remote_addr.aid == AID_UNSPEC ? p->pt->aid : @@ -420,30 +398,37 @@ mrt_dump_entry_mp(struct mrt *mrt, struct prefix *p, uint16_t snum, switch (aid) { case AID_INET: case AID_VPN_IPv4: - DUMP_SHORT(h2buf, AFI_IPv4); - DUMP_NLONG(h2buf, peer->local_v4_addr.v4.s_addr); - DUMP_NLONG(h2buf, peer->remote_addr.v4.s_addr); + if (ibuf_add_n16(h2buf, AFI_IPv4) == -1) + goto fail; + if (ibuf_add(h2buf, &peer->local_v4_addr.v4, + sizeof(peer->local_v4_addr.v4)) == -1 || + ibuf_add(h2buf, &peer->remote_addr.v4, + sizeof(peer->remote_addr.v4)) == -1) + goto fail; break; case AID_INET6: case AID_VPN_IPv6: - DUMP_SHORT(h2buf, AFI_IPv6); - if (ibuf_add(h2buf, &peer->local_v6_addr.v6, - sizeof(struct in6_addr)) == -1 || - ibuf_add(h2buf, &peer->remote_addr.v6, - sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_entry_mp: ibuf_add error"); + if (ibuf_add_n16(h2buf, AFI_IPv6) == -1) + goto fail; + if (ibuf_add(h2buf, &peer->local_v6_addr.v6, + sizeof(peer->local_v6_addr.v6)) == -1 || + ibuf_add(h2buf, &peer->remote_addr.v6, + sizeof(peer->remote_addr.v6)) == -1) goto fail; - } break; default: log_warnx("king bula found new AF %d in %s", aid, __func__); goto fail; } - DUMP_SHORT(h2buf, 0); /* view */ - DUMP_SHORT(h2buf, 1); /* status */ + if (ibuf_add_n16(h2buf, 0) == -1) /* view */ + goto fail; + if (ibuf_add_n16(h2buf, 1) == -1) /* status */ + goto fail; /* originated timestamp */ - DUMP_LONG(h2buf, time(NULL) - (getmonotime() - p->lastchange)); + if (ibuf_add_n32(h2buf, time(NULL) - (getmonotime() - + p->lastchange)) == -1) + goto fail; n = prefix_nexthop(p); if (n == NULL) { @@ -455,59 +440,75 @@ mrt_dump_entry_mp(struct mrt *mrt, struct prefix *p, uint16_t snum, switch (p->pt->aid) { case AID_INET: - DUMP_SHORT(h2buf, AFI_IPv4); /* afi */ - DUMP_BYTE(h2buf, SAFI_UNICAST); /* safi */ - DUMP_BYTE(h2buf, 4); /* nhlen */ - DUMP_NLONG(h2buf, nh->v4.s_addr); /* nexthop */ + if (ibuf_add_n16(h2buf, AFI_IPv4) == -1) /* afi */ + goto fail; + if (ibuf_add_n8(h2buf, SAFI_UNICAST) == -1) /* safi */ + goto fail; + if (ibuf_add_n8(h2buf, 4) == -1) /* nhlen */ + goto fail; + if (ibuf_add(h2buf, &nh->v4, sizeof(nh->v4)) == -1) + goto fail; break; case AID_INET6: - DUMP_SHORT(h2buf, AFI_IPv6); /* afi */ - DUMP_BYTE(h2buf, SAFI_UNICAST); /* safi */ - DUMP_BYTE(h2buf, 16); /* nhlen */ - if (ibuf_add(h2buf, &nh->v6, sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_entry_mp: ibuf_add error"); + if (ibuf_add_n16(h2buf, AFI_IPv6) == -1) /* afi */ + goto fail; + if (ibuf_add_n8(h2buf, SAFI_UNICAST) == -1) /* safi */ + goto fail; + if (ibuf_add_n8(h2buf, 16) == -1) /* nhlen */ + goto fail; + if (ibuf_add(h2buf, &nh->v6, sizeof(nh->v6)) == -1) goto fail; - } break; case AID_VPN_IPv4: - DUMP_SHORT(h2buf, AFI_IPv4); /* afi */ - DUMP_BYTE(h2buf, SAFI_MPLSVPN); /* safi */ - DUMP_BYTE(h2buf, sizeof(uint64_t) + sizeof(struct in_addr)); - DUMP_NLONG(h2buf, 0); /* set RD to 0 */ - DUMP_NLONG(h2buf, 0); - DUMP_NLONG(h2buf, nh->v4.s_addr); /* nexthop */ + if (ibuf_add_n16(h2buf, AFI_IPv4) == -1) /* afi */ + goto fail; + if (ibuf_add_n8(h2buf, SAFI_MPLSVPN) == -1) /* safi */ + goto fail; + if (ibuf_add_n8(h2buf, sizeof(uint64_t) + + sizeof(struct in_addr)) == -1) + goto fail; + if (ibuf_add_n64(h2buf, 0) == -1) /* set RD to 0 */ + goto fail; + if (ibuf_add(h2buf, &nh->v4, sizeof(nh->v4)) == -1) + goto fail; break; case AID_VPN_IPv6: - DUMP_SHORT(h2buf, AFI_IPv6); /* afi */ - DUMP_BYTE(h2buf, SAFI_MPLSVPN); /* safi */ - DUMP_BYTE(h2buf, sizeof(uint64_t) + sizeof(struct in6_addr)); - DUMP_NLONG(h2buf, 0); /* set RD to 0 */ - DUMP_NLONG(h2buf, 0); - if (ibuf_add(h2buf, &nh->v6, sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_entry_mp: ibuf_add error"); + if (ibuf_add_n16(h2buf, AFI_IPv6) == -1) /* afi */ + goto fail; + if (ibuf_add_n8(h2buf, SAFI_MPLSVPN) == -1) /* safi */ + goto fail; + if (ibuf_add_n8(h2buf, sizeof(uint64_t) + + sizeof(struct in6_addr)) == -1) + goto fail; + if (ibuf_add_n64(h2buf, 0) == -1) /* set RD to 0 */ + goto fail; + if (ibuf_add(h2buf, &nh->v6, sizeof(nh->v6)) == -1) goto fail; - } break; case AID_FLOWSPECv4: case AID_FLOWSPECv6: - if (p->pt->aid == AID_FLOWSPECv4) - DUMP_SHORT(h2buf, AFI_IPv4); /* afi */ - else - DUMP_SHORT(h2buf, AFI_IPv6); /* afi */ - DUMP_BYTE(h2buf, SAFI_FLOWSPEC); /* safi */ - DUMP_BYTE(h2buf, 0); /* nhlen */ + if (p->pt->aid == AID_FLOWSPECv4) { + if (ibuf_add_n16(h2buf, AFI_IPv4) == -1) /* afi */ + goto fail; + } else { + if (ibuf_add_n16(h2buf, AFI_IPv6) == -1) /* afi */ + goto fail; + } + if (ibuf_add_n8(h2buf, SAFI_FLOWSPEC) == -1) /* safi */ + goto fail; + if (ibuf_add_n8(h2buf, 0) == -1) /* nhlen */ + goto fail; break; default: log_warnx("king bula found new AF in %s", __func__); goto fail; } - if (pt_writebuf(h2buf, p->pt) == -1) { - log_warnx("%s: pt_writebuf error", __func__); + if (pt_writebuf(h2buf, p->pt, 0, 0, 0) == -1) goto fail; - } - DUMP_SHORT(h2buf, len); + if (ibuf_add_n16(h2buf, len) == -1) + goto fail; len += ibuf_size(h2buf); if (mrt_dump_hdr_rde(&hbuf, MSG_PROTOCOL_BGP4MP, BGP4MP_ENTRY, @@ -521,17 +522,18 @@ mrt_dump_entry_mp(struct mrt *mrt, struct prefix *p, uint16_t snum, return (len + MRT_HEADER_SIZE); fail: + log_warn("%s: ibuf error", __func__); ibuf_free(hbuf); ibuf_free(h2buf); ibuf_free(buf); return (-1); } -int +static int mrt_dump_entry(struct mrt *mrt, struct prefix *p, uint16_t snum, struct rde_peer *peer) { - struct ibuf *buf, *hbuf; + struct ibuf *buf, *hbuf = NULL; struct nexthop *nexthop; struct bgpd_addr addr, *nh; size_t len; @@ -556,52 +558,55 @@ mrt_dump_entry(struct mrt *mrt, struct prefix *p, uint16_t snum, } else nh = &nexthop->exit_nexthop; if (mrt_attr_dump(buf, prefix_aspath(p), prefix_communities(p), - nh, 0) == -1) { - log_warnx("mrt_dump_entry: mrt_attr_dump error"); - ibuf_free(buf); - return (-1); - } + nh, 0) == -1) + goto fail; + len = ibuf_size(buf); aid2afi(p->pt->aid, &subtype, &dummy); - if (mrt_dump_hdr_rde(&hbuf, MSG_TABLE_DUMP, subtype, len) == -1) { - ibuf_free(buf); - return (-1); - } + if (mrt_dump_hdr_rde(&hbuf, MSG_TABLE_DUMP, subtype, len) == -1) + goto fail; - DUMP_SHORT(hbuf, 0); - DUMP_SHORT(hbuf, snum); + if (ibuf_add_n16(hbuf, 0) == -1) + goto fail; + if (ibuf_add_n16(hbuf, snum) == -1) + goto fail; pt_getaddr(p->pt, &addr); switch (p->pt->aid) { case AID_INET: - DUMP_NLONG(hbuf, addr.v4.s_addr); + if (ibuf_add(hbuf, &addr.v4, sizeof(addr.v4)) == -1) + goto fail; break; case AID_INET6: - if (ibuf_add(hbuf, &addr.v6, sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_entry: ibuf_add error"); + if (ibuf_add(hbuf, &addr.v6, sizeof(addr.v6)) == -1) goto fail; - } break; } - DUMP_BYTE(hbuf, p->pt->prefixlen); + if (ibuf_add_n8(hbuf, p->pt->prefixlen) == -1) + goto fail; - DUMP_BYTE(hbuf, 1); /* state */ + if (ibuf_add_n8(hbuf, 1) == -1) /* state */ + goto fail; /* originated timestamp */ - DUMP_LONG(hbuf, time(NULL) - (getmonotime() - p->lastchange)); + if (ibuf_add_n32(hbuf, time(NULL) - (getmonotime() - + p->lastchange)) == -1) + goto fail; switch (p->pt->aid) { case AID_INET: - DUMP_NLONG(hbuf, peer->remote_addr.v4.s_addr); + if (ibuf_add(hbuf, &peer->remote_addr.v4, + sizeof(peer->remote_addr.v4)) == -1) + goto fail; break; case AID_INET6: if (ibuf_add(hbuf, &peer->remote_addr.v6, - sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_entry: ibuf_add error"); + sizeof(peer->remote_addr.v6)) == -1) goto fail; - } break; } - DUMP_SHORT(hbuf, peer->short_as); - DUMP_SHORT(hbuf, len); + if (ibuf_add_n16(hbuf, peer->short_as) == -1) + goto fail; + if (ibuf_add_n16(hbuf, len) == -1) + goto fail; ibuf_close(&mrt->wbuf, hbuf); ibuf_close(&mrt->wbuf, buf); @@ -609,6 +614,7 @@ mrt_dump_entry(struct mrt *mrt, struct prefix *p, uint16_t snum, return (len + MRT_HEADER_SIZE); fail: + log_warn("%s: ibuf error", __func__); ibuf_free(hbuf); ibuf_free(buf); return (-1); @@ -619,9 +625,9 @@ mrt_dump_entry_v2_rib(struct rib_entry *re, struct ibuf **nb, struct ibuf **apb, uint16_t *np, uint16_t *app) { struct bgpd_addr addr; - struct ibuf *buf, **bp; + struct ibuf *buf = NULL, **bp; + struct ibuf *tbuf = NULL; struct prefix *p; - size_t len; int addpath; *np = 0; @@ -630,7 +636,6 @@ mrt_dump_entry_v2_rib(struct rib_entry *re, struct ibuf **nb, struct ibuf **apb, TAILQ_FOREACH(p, &re->prefix_h, entry.list.rib) { struct nexthop *nexthop; struct bgpd_addr *nh; - struct ibuf *tbuf; addpath = peer_has_add_path(prefix_peer(p), re->prefix->aid, CAPA_AP_RECV); @@ -643,10 +648,8 @@ mrt_dump_entry_v2_rib(struct rib_entry *re, struct ibuf **nb, struct ibuf **apb, *np += 1; } if ((buf = *bp) == NULL) { - if ((buf = ibuf_dynamic(0, UINT_MAX)) == NULL) { - log_warn("%s: ibuf_dynamic", __func__); + if ((buf = ibuf_dynamic(0, UINT_MAX)) == NULL) goto fail; - } *bp = buf; } @@ -658,41 +661,39 @@ mrt_dump_entry_v2_rib(struct rib_entry *re, struct ibuf **nb, struct ibuf **apb, } else nh = &nexthop->exit_nexthop; - DUMP_SHORT(buf, prefix_peer(p)->mrt_idx); + if (ibuf_add_n16(buf, prefix_peer(p)->mrt_idx) == -1) + goto fail; /* originated timestamp */ - DUMP_LONG(buf, time(NULL) - (getmonotime() - p->lastchange)); + if (ibuf_add_n32(buf, time(NULL) - (getmonotime() - + p->lastchange)) == -1) + goto fail; /* RFC8050: path-id if add-path is used */ if (addpath) - DUMP_LONG(buf, p->path_id); + if (ibuf_add_n32(buf, p->path_id) == -1) + goto fail; - if ((tbuf = ibuf_dynamic(0, MAX_PKTSIZE)) == NULL) { - log_warn("%s: ibuf_dynamic", __func__); + if ((tbuf = ibuf_dynamic(0, MAX_PKTSIZE)) == NULL) goto fail; - } if (mrt_attr_dump(tbuf, prefix_aspath(p), prefix_communities(p), - nh, 1) == -1) { - log_warnx("%s: mrt_attr_dump error", __func__); - ibuf_free(tbuf); + nh, 1) == -1) goto fail; - } - len = ibuf_size(tbuf); - DUMP_SHORT(buf, (uint16_t)len); - if (ibuf_add(buf, tbuf->buf, len) == -1) { - log_warn("%s: ibuf_add error", __func__); - ibuf_free(tbuf); + if (ibuf_add_n16(buf, ibuf_size(tbuf)) == -1) + goto fail; + if (ibuf_add_buf(buf, tbuf) == -1) goto fail; - } ibuf_free(tbuf); + tbuf = NULL; } return 0; fail: + ibuf_free(tbuf); return -1; } -int +static int mrt_dump_entry_v2(struct mrt *mrt, struct rib_entry *re, uint32_t snum) { struct ibuf *hbuf = NULL, *nbuf = NULL, *apbuf = NULL, *pbuf; @@ -726,15 +727,15 @@ mrt_dump_entry_v2(struct mrt *mrt, struct rib_entry *re, uint32_t snum) aid2afi(re->prefix->aid, &afi, &safi); /* first add 3-bytes AFI/SAFI */ - DUMP_SHORT(pbuf, afi); - DUMP_BYTE(pbuf, safi); + if (ibuf_add_n16(pbuf, afi) == -1) + goto fail; + if (ibuf_add_n8(pbuf, safi) == -1) + goto fail; break; } - if (pt_writebuf(pbuf, re->prefix) == -1) { - log_warnx("%s: pt_writebuf error", __func__); + if (pt_writebuf(pbuf, re->prefix, 0, 0, 0) == -1) goto fail; - } hlen = sizeof(snum) + sizeof(nump) + ibuf_size(pbuf); @@ -747,12 +748,12 @@ mrt_dump_entry_v2(struct mrt *mrt, struct rib_entry *re, uint32_t snum) len) == -1) goto fail; - DUMP_LONG(hbuf, snum); - if (ibuf_add(hbuf, pbuf->buf, ibuf_size(pbuf)) == -1) { - log_warn("%s: ibuf_add error", __func__); + if (ibuf_add_n32(hbuf, snum) == -1) + goto fail; + if (ibuf_add_buf(hbuf, pbuf) == -1) + goto fail; + if (ibuf_add_n16(hbuf, nump) == -1) goto fail; - } - DUMP_SHORT(hbuf, nump); ibuf_close(&mrt->wbuf, hbuf); ibuf_close(&mrt->wbuf, nbuf); @@ -766,12 +767,12 @@ mrt_dump_entry_v2(struct mrt *mrt, struct rib_entry *re, uint32_t snum) len) == -1) goto fail; - DUMP_LONG(hbuf, snum); - if (ibuf_add(hbuf, pbuf->buf, ibuf_size(pbuf)) == -1) { - log_warn("%s: ibuf_add error", __func__); + if (ibuf_add_n32(hbuf, snum) == -1) + goto fail; + if (ibuf_add_buf(hbuf, pbuf) == -1) + goto fail; + if (ibuf_add_n16(hbuf, apnump) == -1) goto fail; - } - DUMP_SHORT(hbuf, apnump); ibuf_close(&mrt->wbuf, hbuf); ibuf_close(&mrt->wbuf, apbuf); @@ -782,6 +783,7 @@ mrt_dump_entry_v2(struct mrt *mrt, struct rib_entry *re, uint32_t snum) ibuf_free(pbuf); return (0); fail: + log_warn("%s: ibuf error", __func__); ibuf_free(apbuf); ibuf_free(nbuf); ibuf_free(hbuf); @@ -822,29 +824,27 @@ mrt_dump_v2_hdr(struct mrt *mrt, struct bgpd_config *conf) return (-1); } - DUMP_NLONG(buf, conf->bgpid); + if (ibuf_add(buf, &conf->bgpid, sizeof(conf->bgpid)) == -1) + goto fail; nlen = strlen(mrt->rib); if (nlen > 0) nlen += 1; - DUMP_SHORT(buf, nlen); - if (ibuf_add(buf, mrt->rib, nlen) == -1) { - log_warn("%s: ibuf_add error", __func__); + if (ibuf_add_n16(buf, nlen) == -1) + goto fail; + if (ibuf_add(buf, mrt->rib, nlen) == -1) goto fail; - } off = ibuf_size(buf); - if (ibuf_reserve(buf, sizeof(nump)) == NULL) { - log_warn("%s: ibuf_reserve error", __func__); + if (ibuf_add_zero(buf, sizeof(nump)) == -1) goto fail; - } arg.nump = 0; arg.buf = buf; peer_foreach(mrt_dump_v2_hdr_peer, &arg); if (arg.nump == -1) goto fail; - nump = htons(arg.nump); - memcpy(ibuf_seek(buf, off, sizeof(nump)), &nump, sizeof(nump)); + if (ibuf_set_n16(buf, off, arg.nump) == -1) + goto fail; len = ibuf_size(buf); if (mrt_dump_hdr_rde(&hbuf, MSG_TABLE_DUMP_V2, @@ -856,12 +856,13 @@ mrt_dump_v2_hdr(struct mrt *mrt, struct bgpd_config *conf) return (0); fail: + log_warn("%s: ibuf error", __func__); ibuf_free(hbuf); ibuf_free(buf); return (-1); } -int +static int mrt_dump_peer(struct ibuf *buf, struct rde_peer *peer) { uint8_t type = 0; @@ -871,35 +872,41 @@ mrt_dump_peer(struct ibuf *buf, struct rde_peer *peer) if (peer->remote_addr.aid == AID_INET6) type |= MRT_DUMP_V2_PEER_BIT_I; - DUMP_BYTE(buf, type); - DUMP_LONG(buf, peer->remote_bgpid); + if (ibuf_add_n8(buf, type) == -1) + goto fail; + if (ibuf_add_n32(buf, peer->remote_bgpid) == -1) + goto fail; switch (peer->remote_addr.aid) { case AID_INET: - DUMP_NLONG(buf, peer->remote_addr.v4.s_addr); + if (ibuf_add(buf, &peer->remote_addr.v4, + sizeof(peer->remote_addr.v4)) == -1) + goto fail; break; case AID_INET6: if (ibuf_add(buf, &peer->remote_addr.v6, - sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_peer: ibuf_add error"); + sizeof(peer->remote_addr.v6)) == -1) goto fail; - } break; case AID_UNSPEC: /* XXX special handling for peerself? */ - DUMP_NLONG(buf, 0); + if (ibuf_add_n32(buf, 0) == -1) + goto fail; break; default: log_warnx("king bula found new AF in %s", __func__); goto fail; } - if (peer->capa.as4byte) - DUMP_LONG(buf, peer->conf.remote_as); - else - DUMP_SHORT(buf, peer->short_as); - + if (peer->capa.as4byte) { + if (ibuf_add_n32(buf, peer->conf.remote_as) == -1) + goto fail; + } else { + if (ibuf_add_n16(buf, peer->short_as) == -1) + goto fail; + } return (0); fail: + log_warn("%s: ibuf error", __func__); return (-1); } @@ -935,23 +942,24 @@ mrt_done(struct mrt *mrtbuf) mrtbuf->state = MRT_STATE_REMOVE; } -int +static int mrt_dump_hdr_se(struct ibuf ** bp, struct peer *peer, uint16_t type, uint16_t subtype, uint32_t len, int swap) { struct timespec time; if ((*bp = ibuf_dynamic(MRT_ET_HEADER_SIZE, MRT_ET_HEADER_SIZE + - MRT_BGP4MP_AS4_IPv6_HEADER_SIZE + len)) == NULL) { - log_warn("mrt_dump_hdr_se: ibuf_dynamic error"); + MRT_BGP4MP_AS4_IPv6_HEADER_SIZE + len)) == NULL) return (-1); - } clock_gettime(CLOCK_REALTIME, &time); - DUMP_LONG(*bp, time.tv_sec); - DUMP_SHORT(*bp, type); - DUMP_SHORT(*bp, subtype); + if (ibuf_add_n32(*bp, time.tv_sec) == -1) + goto fail; + if (ibuf_add_n16(*bp, type) == -1) + goto fail; + if (ibuf_add_n16(*bp, subtype) == -1) + goto fail; switch (peer->local.aid) { case AID_INET: @@ -977,56 +985,67 @@ mrt_dump_hdr_se(struct ibuf ** bp, struct peer *peer, uint16_t type, goto fail; } - DUMP_LONG(*bp, len); + if (ibuf_add_n32(*bp, len) == -1) + goto fail; /* millisecond field use by the _ET format */ - DUMP_LONG(*bp, time.tv_nsec / 1000); + if (ibuf_add_n32(*bp, time.tv_nsec / 1000) == -1) + goto fail; if (subtype == BGP4MP_STATE_CHANGE_AS4 || subtype == BGP4MP_MESSAGE_AS4 || subtype == BGP4MP_MESSAGE_AS4_ADDPATH) { if (!swap) - DUMP_LONG(*bp, peer->conf.local_as); - DUMP_LONG(*bp, peer->conf.remote_as); + if (ibuf_add_n32(*bp, peer->conf.local_as) == -1) + goto fail; + if (ibuf_add_n32(*bp, peer->conf.remote_as) == -1) + goto fail; if (swap) - DUMP_LONG(*bp, peer->conf.local_as); + if (ibuf_add_n32(*bp, peer->conf.local_as) == -1) + goto fail; } else { if (!swap) - DUMP_SHORT(*bp, peer->conf.local_short_as); - DUMP_SHORT(*bp, peer->short_as); + if (ibuf_add_n16(*bp, peer->conf.local_short_as) == -1) + goto fail; + if (ibuf_add_n16(*bp, peer->short_as) == -1) + goto fail; if (swap) - DUMP_SHORT(*bp, peer->conf.local_short_as); + if (ibuf_add_n16(*bp, peer->conf.local_short_as) == -1) + goto fail; } - DUMP_SHORT(*bp, /* ifindex */ 0); + if (ibuf_add_n16(*bp, /* ifindex */ 0) == -1) + goto fail; switch (peer->local.aid) { case AID_INET: - DUMP_SHORT(*bp, AFI_IPv4); + if (ibuf_add_n16(*bp, AFI_IPv4) == -1) + goto fail; if (!swap) - DUMP_NLONG(*bp, peer->local.v4.s_addr); - DUMP_NLONG(*bp, peer->remote.v4.s_addr); + if (ibuf_add(*bp, &peer->local.v4, + sizeof(peer->local.v4)) == -1) + goto fail; + if (ibuf_add(*bp, &peer->remote.v4, + sizeof(peer->remote.v4)) == -1) + goto fail; if (swap) - DUMP_NLONG(*bp, peer->local.v4.s_addr); + if (ibuf_add(*bp, &peer->local.v4, + sizeof(peer->local.v4)) == -1) + goto fail; break; case AID_INET6: - DUMP_SHORT(*bp, AFI_IPv6); + if (ibuf_add_n16(*bp, AFI_IPv6) == -1) + goto fail; if (!swap) if (ibuf_add(*bp, &peer->local.v6, - sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_hdr_se: ibuf_add error"); + sizeof(peer->local.v6)) == -1) goto fail; - } if (ibuf_add(*bp, &peer->remote.v6, - sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_hdr_se: ibuf_add error"); + sizeof(peer->remote.v6)) == -1) goto fail; - } if (swap) if (ibuf_add(*bp, &peer->local.v6, - sizeof(struct in6_addr)) == -1) { - log_warn("mrt_dump_hdr_se: ibuf_add error"); + sizeof(peer->local.v6)) == -1) goto fail; - } break; } @@ -1034,6 +1053,7 @@ mrt_dump_hdr_se(struct ibuf ** bp, struct peer *peer, uint16_t type, fail: ibuf_free(*bp); + *bp = NULL; return (-1); } @@ -1045,16 +1065,17 @@ mrt_dump_hdr_rde(struct ibuf **bp, uint16_t type, uint16_t subtype, if ((*bp = ibuf_dynamic(MRT_HEADER_SIZE, MRT_HEADER_SIZE + MRT_BGP4MP_AS4_IPv6_HEADER_SIZE + MRT_BGP4MP_IPv6_ENTRY_SIZE)) == - NULL) { - log_warn("mrt_dump_hdr_rde: ibuf_dynamic error"); + NULL) return (-1); - } clock_gettime(CLOCK_REALTIME, &time); - DUMP_LONG(*bp, time.tv_sec); - DUMP_SHORT(*bp, type); - DUMP_SHORT(*bp, subtype); + if (ibuf_add_n32(*bp, time.tv_sec) == -1) + goto fail; + if (ibuf_add_n16(*bp, type) == -1) + goto fail; + if (ibuf_add_n16(*bp, subtype) == -1) + goto fail; switch (type) { case MSG_TABLE_DUMP: @@ -1066,11 +1087,13 @@ mrt_dump_hdr_rde(struct ibuf **bp, uint16_t type, uint16_t subtype, len += MRT_DUMP_HEADER_SIZE_V6; break; } - DUMP_LONG(*bp, len); + if (ibuf_add_n32(*bp, len) == -1) + goto fail; break; case MSG_PROTOCOL_BGP4MP: case MSG_TABLE_DUMP_V2: - DUMP_LONG(*bp, len); + if (ibuf_add_n32(*bp, len) == -1) + goto fail; break; default: log_warnx("mrt_dump_hdr_rde: unsupported type"); @@ -1099,14 +1122,8 @@ mrt_write(struct mrt *mrt) void mrt_clean(struct mrt *mrt) { - struct ibuf *b; - close(mrt->wbuf.fd); - while ((b = TAILQ_FIRST(&mrt->wbuf.bufs))) { - TAILQ_REMOVE(&mrt->wbuf.bufs, b, entry); - ibuf_free(b); - } - mrt->wbuf.queued = 0; + msgbuf_clear(&mrt->wbuf); } static struct imsgbuf *mrt_imsgbuf[2]; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 894e541f5..0a9fd1169 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.606 2023/06/12 12:48:07 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.608 2023/07/12 14:45:42 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -86,8 +86,7 @@ static void rde_rpki_reload(void); static int rde_roa_reload(void); static int rde_aspa_reload(void); int rde_update_queue_pending(void); -void rde_update_queue_runner(void); -void rde_update6_queue_runner(uint8_t); +void rde_update_queue_runner(uint8_t); struct rde_prefixset *rde_find_prefixset(char *, struct rde_prefixset_head *); void rde_mark_prefixsets_dirty(struct rde_prefixset_head *, struct rde_prefixset_head *); @@ -310,9 +309,8 @@ rde_main(int debug, int verbose) rib_dump_runner(); nexthop_runner(); if (ibuf_se && ibuf_se->w.queued < SESS_MSG_HIGH_MARK) { - rde_update_queue_runner(); - for (aid = AID_INET6; aid < AID_MAX; aid++) - rde_update6_queue_runner(aid); + for (aid = AID_MIN; aid < AID_MAX; aid++) + rde_update_queue_runner(aid); } /* commit pftable once per poll loop */ rde_commit_pftable(); @@ -2196,7 +2194,7 @@ bad_flags: goto bad_flags; if (peer->conf.ebgp) { /* ignore local-pref attr on non ibgp peers */ - plen += 4; + plen += attr_len; break; } if (a->flags & F_ATTR_LOCALPREF) @@ -2220,7 +2218,7 @@ bad_flags: * RFC 7606 */ log_peer_warnx(&peer->conf, "bad AGGREGATOR, " - "partial attribute ignored"); + "attribute discarded"); plen += attr_len; break; } @@ -2268,7 +2266,6 @@ bad_flags: a->flags |= F_ATTR_PARSE_ERR; log_peer_warnx(&peer->conf, "bad COMMUNITIES, " "path invalidated and prefix withdrawn"); - break; } plen += attr_len; break; @@ -2285,7 +2282,6 @@ bad_flags: a->flags |= F_ATTR_PARSE_ERR; log_peer_warnx(&peer->conf, "bad LARGE COMMUNITIES, " "path invalidated and prefix withdrawn"); - break; } plen += attr_len; break; @@ -2302,7 +2298,6 @@ bad_flags: a->flags |= F_ATTR_PARSE_ERR; log_peer_warnx(&peer->conf, "bad EXT_COMMUNITIES, " "path invalidated and prefix withdrawn"); - break; } plen += attr_len; break; @@ -2349,10 +2344,8 @@ bad_flags: case ATTR_AS4_AGGREGATOR: if (attr_len != 8) { /* see ATTR_AGGREGATOR ... */ - if ((flags & ATTR_PARTIAL) == 0) - goto bad_len; log_peer_warnx(&peer->conf, "bad AS4_AGGREGATOR, " - "partial attribute ignored"); + "attribute discarded"); plen += attr_len; break; } @@ -2388,6 +2381,7 @@ bad_flags: a->flags |= F_ATTR_PARSE_ERR; log_peer_warnx(&peer->conf, "bad OTC, " "path invalidated and prefix withdrawn"); + plen += attr_len; break; } if (!CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE, @@ -3456,69 +3450,11 @@ rde_update_queue_pending(void) } void -rde_update_queue_runner(void) +rde_update_queue_runner(uint8_t aid) { struct rde_peer *peer; - int r, sent, max = RDE_RUNNER_ROUNDS, eor; - uint16_t len, wpos; - - len = sizeof(queue_buf) - MSGSIZE_HEADER; - do { - sent = 0; - RB_FOREACH(peer, peer_tree, &peertable) { - if (peer->conf.id == 0) - continue; - if (peer->state != PEER_UP) - continue; - if (peer->throttled) - continue; - eor = 0; - wpos = 0; - /* first withdraws, save 2 bytes for path attributes */ - if ((r = up_dump_withdraws(queue_buf, len - 2, peer, - AID_INET)) == -1) - continue; - wpos += r; - - /* now bgp path attributes unless it is the EoR mark */ - if (up_is_eor(peer, AID_INET)) { - eor = 1; - memset(queue_buf + wpos, 0, 2); - wpos += 2; - } else { - r = up_dump_attrnlri(queue_buf + wpos, - len - wpos, peer); - wpos += r; - } - - /* finally send message to SE */ - if (wpos > 4) { - if (imsg_compose(ibuf_se, IMSG_UPDATE, - peer->conf.id, 0, -1, queue_buf, - wpos) == -1) - fatal("%s %d imsg_compose error", - __func__, __LINE__); - sent++; - } - if (eor) { - int sent_eor = peer->sent_eor & (1 << AID_INET); - if (peer->capa.grestart.restart && !sent_eor) - rde_peer_send_eor(peer, AID_INET); - if (peer->capa.enhanced_rr && sent_eor) - rde_peer_send_rrefresh(peer, AID_INET, - ROUTE_REFRESH_END_RR); - } - } - max -= sent; - } while (sent != 0 && max > 0); -} - -void -rde_update6_queue_runner(uint8_t aid) -{ - struct rde_peer *peer; - int r, sent, max = RDE_RUNNER_ROUNDS / 2; - uint16_t len; + struct ibuf *buf; + int sent, max = RDE_RUNNER_ROUNDS; /* first withdraws ... */ do { @@ -3530,22 +3466,26 @@ rde_update6_queue_runner(uint8_t aid) continue; if (peer->throttled) continue; - len = sizeof(queue_buf) - MSGSIZE_HEADER; - r = up_dump_mp_unreach(queue_buf, len, peer, aid); - if (r == -1) + if (RB_EMPTY(&peer->withdraws[aid])) continue; - /* finally send message to SE */ - if (imsg_compose(ibuf_se, IMSG_UPDATE, peer->conf.id, - 0, -1, queue_buf, r) == -1) - fatal("%s %d imsg_compose error", __func__, - __LINE__); + + if ((buf = ibuf_dynamic(4, 4096 - MSGSIZE_HEADER)) == + NULL) + fatal("%s", __func__); + if (up_dump_withdraws(buf, peer, aid) == -1) { + ibuf_free(buf); + continue; + } + if (imsg_compose_ibuf(ibuf_se, IMSG_UPDATE, + peer->conf.id, 0, buf) == -1) + fatal("%s: imsg_create error", __func__); sent++; } max -= sent; } while (sent != 0 && max > 0); /* ... then updates */ - max = RDE_RUNNER_ROUNDS / 2; + max = RDE_RUNNER_ROUNDS; do { sent = 0; RB_FOREACH(peer, peer_tree, &peertable) { @@ -3555,7 +3495,9 @@ rde_update6_queue_runner(uint8_t aid) continue; if (peer->throttled) continue; - len = sizeof(queue_buf) - MSGSIZE_HEADER; + if (RB_EMPTY(&peer->updates[aid])) + continue; + if (up_is_eor(peer, aid)) { int sent_eor = peer->sent_eor & (1 << aid); if (peer->capa.grestart.restart && !sent_eor) @@ -3565,15 +3507,17 @@ rde_update6_queue_runner(uint8_t aid) ROUTE_REFRESH_END_RR); continue; } - r = up_dump_mp_reach(queue_buf, len, peer, aid); - if (r == 0) - continue; - /* finally send message to SE */ - if (imsg_compose(ibuf_se, IMSG_UPDATE, peer->conf.id, - 0, -1, queue_buf, r) == -1) - fatal("%s %d imsg_compose error", __func__, - __LINE__); + if ((buf = ibuf_dynamic(4, 4096 - MSGSIZE_HEADER)) == + NULL) + fatal("%s", __func__); + if (up_dump_update(buf, peer, aid) == -1) { + ibuf_free(buf); + continue; + } + if (imsg_compose_ibuf(ibuf_se, IMSG_UPDATE, + peer->conf.id, 0, buf) == -1) + fatal("%s: imsg_compose_ibuf error", __func__); sent++; } max -= sent; diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index d7a0aebba..d2e885077 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.294 2023/06/12 12:48:07 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.295 2023/07/12 14:45:43 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker and @@ -447,10 +447,7 @@ int community_add(struct rde_community *, int, void *, size_t); int community_large_add(struct rde_community *, int, void *, size_t); int community_ext_add(struct rde_community *, int, int, void *, size_t); -int community_write(struct rde_community *, void *, uint16_t); -int community_large_write(struct rde_community *, void *, uint16_t); -int community_ext_write(struct rde_community *, int, void *, uint16_t); -int community_writebuf(struct ibuf *, struct rde_community *); +int community_writebuf(struct rde_community *, uint8_t, int, struct ibuf *); void communities_shutdown(void); struct rde_community *communities_lookup(struct rde_community *); @@ -519,8 +516,7 @@ struct pt_entry *pt_add_flow(struct flowspec *); void pt_remove(struct pt_entry *); struct pt_entry *pt_lookup(struct bgpd_addr *); int pt_prefix_cmp(const struct pt_entry *, const struct pt_entry *); -int pt_write(u_char *, int, struct pt_entry *, int); -int pt_writebuf(struct ibuf *, struct pt_entry *); +int pt_writebuf(struct ibuf *, struct pt_entry *, int, int, uint32_t); static inline struct pt_entry * pt_ref(struct pt_entry *pt) @@ -710,10 +706,8 @@ void up_generate_addpath_all(struct rde_peer *, struct rib_entry *, struct prefix *, struct prefix *); void up_generate_default(struct rde_peer *, uint8_t); int up_is_eor(struct rde_peer *, uint8_t); -int up_dump_withdraws(u_char *, int, struct rde_peer *, uint8_t); -int up_dump_mp_unreach(u_char *, int, struct rde_peer *, uint8_t); -int up_dump_attrnlri(u_char *, int, struct rde_peer *); -int up_dump_mp_reach(u_char *, int, struct rde_peer *, uint8_t); +int up_dump_withdraws(struct ibuf *, struct rde_peer *, uint8_t); +int up_dump_update(struct ibuf *, struct rde_peer *, uint8_t); /* rde_aspa.c */ void aspa_validation(struct rde_aspa *, struct aspath *, diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c index 982f5cdac..b1b495747 100644 --- a/usr.sbin/bgpd/rde_attr.c +++ b/usr.sbin/bgpd/rde_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_attr.c,v 1.133 2023/06/12 12:10:17 claudio Exp $ */ +/* $OpenBSD: rde_attr.c,v 1.134 2023/07/12 14:45:43 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker @@ -29,42 +29,6 @@ #include "rde.h" #include "log.h" -int -attr_write(void *p, uint16_t p_len, uint8_t flags, uint8_t type, - void *data, uint16_t data_len) -{ - u_char *b = p; - uint16_t tmp, tot_len = 2; /* attribute header (without len) */ - - flags &= ~ATTR_DEFMASK; - if (data_len > 255) { - tot_len += 2 + data_len; - flags |= ATTR_EXTLEN; - } else { - tot_len += 1 + data_len; - } - - if (tot_len > p_len) - return (-1); - - *b++ = flags; - *b++ = type; - if (data_len > 255) { - tmp = htons(data_len); - memcpy(b, &tmp, sizeof(tmp)); - b += 2; - } else - *b++ = (u_char)data_len; - - if (data == NULL) - return (tot_len - data_len); - - if (data_len != 0) - memcpy(b, data, data_len); - - return (tot_len); -} - int attr_writebuf(struct ibuf *buf, uint8_t flags, uint8_t type, void *data, uint16_t data_len) diff --git a/usr.sbin/bgpd/rde_community.c b/usr.sbin/bgpd/rde_community.c index f148045f7..d7a8717f4 100644 --- a/usr.sbin/bgpd/rde_community.c +++ b/usr.sbin/bgpd/rde_community.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_community.c,v 1.12 2023/06/17 08:05:48 claudio Exp $ */ +/* $OpenBSD: rde_community.c,v 1.13 2023/07/12 14:45:43 claudio Exp $ */ /* * Copyright (c) 2019 Claudio Jeker @@ -225,10 +225,9 @@ insert_community(struct rde_community *comm, struct community *c) struct community *new; int newsize = comm->size + 8; - if ((new = reallocarray(comm->communities, newsize, - sizeof(struct community))) == NULL) + if ((new = recallocarray(comm->communities, comm->size, + newsize, sizeof(struct community))) == NULL) fatal(__func__); - memset(new + comm->size, 0, 8 * sizeof(struct community)); comm->communities = new; comm->size = newsize; } @@ -256,6 +255,8 @@ insert_community(struct rde_community *comm, struct community *c) static int non_transitive_ext_community(struct community *c) { + if ((uint8_t)c->flags != COMMUNITY_TYPE_EXT) + return 0; if ((c->data3 >> 8) & EXT_COMMUNITY_NON_TRANSITIVE) return 1; return 0; @@ -514,228 +515,84 @@ community_ext_add(struct rde_community *comm, int flags, int ebgp, /* * Convert communities back to the wireformat. - * This function needs to make sure that the attribute buffer is overflowed - * while writing out the communities. - * - community_write for ATTR_COMMUNITUES - * - community_large_write for ATTR_LARGE_COMMUNITIES - * - community_ext_write for ATTR_EXT_COMMUNITIES - * When writing ATTR_EXT_COMMUNITIES non-transitive communities need to - * be skipped if it is sent to an ebgp peer. + * When writing ATTR_EXT_COMMUNITIES non-transitive communities need to + * be skipped if they are sent to an ebgp peer. */ int -community_write(struct rde_community *comm, void *buf, uint16_t len) -{ - uint8_t *b = buf; - uint16_t c; - size_t n = 0; - int l, r, flags = ATTR_OPTIONAL | ATTR_TRANSITIVE; - - if (comm->flags & PARTIAL_COMMUNITIES) - flags |= ATTR_PARTIAL; - - /* first count how many communities will be written */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_BASIC) - n++; - - if (n == 0) - return 0; - - /* write attribute header */ - r = attr_write(b, len, flags, ATTR_COMMUNITIES, NULL, n * 4); - if (r == -1) - return -1; - b += r; - - /* write out the communities */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_BASIC) { - c = htons(comm->communities[l].data1); - memcpy(b, &c, sizeof(c)); - b += sizeof(c); - r += sizeof(c); - - c = htons(comm->communities[l].data2); - memcpy(b, &c, sizeof(c)); - b += sizeof(c); - r += sizeof(c); - } - - return r; -} - -int -community_large_write(struct rde_community *comm, void *buf, uint16_t len) -{ - uint8_t *b = buf; - uint32_t c; - size_t n = 0; - int l, r, flags = ATTR_OPTIONAL | ATTR_TRANSITIVE; - - if (comm->flags & PARTIAL_LARGE_COMMUNITIES) - flags |= ATTR_PARTIAL; - - /* first count how many communities will be written */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_LARGE) - n++; - - if (n == 0) - return 0; - - /* write attribute header */ - r = attr_write(b, len, flags, ATTR_LARGE_COMMUNITIES, NULL, n * 12); - if (r == -1) - return -1; - b += r; - - /* write out the communities */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_LARGE) { - c = htonl(comm->communities[l].data1); - memcpy(b, &c, sizeof(c)); - b += sizeof(c); - r += sizeof(c); - - c = htonl(comm->communities[l].data2); - memcpy(b, &c, sizeof(c)); - b += sizeof(c); - r += sizeof(c); - - c = htonl(comm->communities[l].data3); - memcpy(b, &c, sizeof(c)); - b += sizeof(c); - r += sizeof(c); - } - - return r; -} - -int -community_ext_write(struct rde_community *comm, int ebgp, void *buf, - uint16_t len) +community_writebuf(struct rde_community *comm, uint8_t type, int ebgp, + struct ibuf *buf) { struct community *cp; - uint8_t *b = buf; uint64_t ext; - size_t n = 0; - int l, r, flags = ATTR_OPTIONAL | ATTR_TRANSITIVE; + int l, size, start, end, num; + int flags = ATTR_OPTIONAL | ATTR_TRANSITIVE; + uint8_t t; - if (comm->flags & PARTIAL_EXT_COMMUNITIES) - flags |= ATTR_PARTIAL; + switch (type) { + case ATTR_COMMUNITIES: + if (comm->flags & PARTIAL_COMMUNITIES) + flags |= ATTR_PARTIAL; + size = 4; + t = COMMUNITY_TYPE_BASIC; + break; + case ATTR_EXT_COMMUNITIES: + if (comm->flags & PARTIAL_EXT_COMMUNITIES) + flags |= ATTR_PARTIAL; + size = 8; + t = COMMUNITY_TYPE_EXT; + break; + case ATTR_LARGE_COMMUNITIES: + if (comm->flags & PARTIAL_LARGE_COMMUNITIES) + flags |= ATTR_PARTIAL; + size = 12; + t = COMMUNITY_TYPE_LARGE; + break; + default: + return -1; + } /* first count how many communities will be written */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_EXT && !(ebgp && - non_transitive_ext_community(&comm->communities[l]))) - n++; + num = 0; + start = -1; + for (l = 0; l < comm->nentries; l++) { + cp = &comm->communities[l]; - if (n == 0) + if (ebgp && non_transitive_ext_community(cp)) + continue; + if ((uint8_t)cp->flags == t) { + num++; + if (start == -1) + start = l; + } + if ((uint8_t)cp->flags > t) + break; + } + end = l; + + /* no communities for this type present */ + if (num == 0) return 0; - /* write attribute header */ - r = attr_write(b, len, flags, ATTR_EXT_COMMUNITIES, NULL, n * 8); - if (r == -1) + if (num > INT16_MAX / size) + return -1; + + /* write attribute header */ + if (attr_writebuf(buf, flags, type, NULL, num * size) == -1) return -1; - b += r; /* write out the communities */ - for (l = 0; l < comm->nentries; l++) { - cp = comm->communities + l; - if ((uint8_t)cp->flags == COMMUNITY_TYPE_EXT && !(ebgp && - non_transitive_ext_community(cp))) { - ext = (uint64_t)cp->data3 << 48; - switch ((cp->data3 >> 8) & EXT_COMMUNITY_VALUE) { - case EXT_COMMUNITY_TRANS_TWO_AS: - case EXT_COMMUNITY_TRANS_OPAQUE: - case EXT_COMMUNITY_TRANS_EVPN: - ext |= ((uint64_t)cp->data1 & 0xffff) << 32; - ext |= (uint64_t)cp->data2; - break; - case EXT_COMMUNITY_TRANS_FOUR_AS: - case EXT_COMMUNITY_TRANS_IPV4: - ext |= (uint64_t)cp->data1 << 16; - ext |= (uint64_t)cp->data2 & 0xffff; - break; - } - ext = htobe64(ext); - memcpy(b, &ext, sizeof(ext)); - b += sizeof(ext); - r += sizeof(ext); - } - } + for (l = start; l < end; l++) { + cp = &comm->communities[l]; - return r; -} - -/* - * Convert communities back to the wireformat and dump them into the ibuf buf. - * This function is used by the mrt dump code. - */ -int -community_writebuf(struct ibuf *buf, struct rde_community *comm) -{ - size_t basic_n = 0, large_n = 0, ext_n = 0; - int l, flags; - - /* first count how many communities will be written */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_BASIC) - basic_n++; - else if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_EXT) - ext_n++; - else if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_LARGE) - large_n++; - - - if (basic_n != 0) { - /* write attribute header */ - flags = ATTR_OPTIONAL | ATTR_TRANSITIVE; - if (comm->flags & PARTIAL_COMMUNITIES) - flags |= ATTR_PARTIAL; - - if (attr_writebuf(buf, flags, ATTR_COMMUNITIES, NULL, - basic_n * 4) == -1) - return -1; - - /* write out the communities */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_BASIC) { - uint16_t c; - c = htons(comm->communities[l].data1); - if (ibuf_add(buf, &c, sizeof(c)) == -1) - return (-1); - c = htons(comm->communities[l].data2); - if (ibuf_add(buf, &c, sizeof(c)) == -1) - return (-1); - } - } - if (ext_n != 0) { - /* write attribute header */ - flags = ATTR_OPTIONAL | ATTR_TRANSITIVE; - if (comm->flags & PARTIAL_COMMUNITIES) - flags |= ATTR_PARTIAL; - - if (attr_writebuf(buf, flags, ATTR_EXT_COMMUNITIES, NULL, - ext_n * 8) == -1) - return -1; - - /* write out the communities */ - for (l = 0; l < comm->nentries; l++) { - struct community *cp; - uint64_t ext; - - cp = comm->communities + l; - if ((uint8_t)cp->flags != COMMUNITY_TYPE_EXT) + switch (type) { + case ATTR_COMMUNITIES: + if (ibuf_add_n16(buf, cp->data1) == -1) + return -1; + if (ibuf_add_n16(buf, cp->data2) == -1) + return -1; + break; + case ATTR_EXT_COMMUNITIES: + if (ebgp && non_transitive_ext_community(cp)) continue; ext = (uint64_t)cp->data3 << 48; @@ -752,38 +609,19 @@ community_writebuf(struct ibuf *buf, struct rde_community *comm) ext |= (uint64_t)cp->data2 & 0xffff; break; } - ext = htobe64(ext); - if (ibuf_add(buf, &ext, sizeof(ext)) == -1) - return (-1); + if (ibuf_add_n64(buf, ext) == -1) + return -1; + break; + case ATTR_LARGE_COMMUNITIES: + if (ibuf_add_n32(buf, cp->data1) == -1) + return -1; + if (ibuf_add_n32(buf, cp->data2) == -1) + return -1; + if (ibuf_add_n32(buf, cp->data3) == -1) + return -1; + break; } } - if (large_n != 0) { - /* write attribute header */ - flags = ATTR_OPTIONAL | ATTR_TRANSITIVE; - if (comm->flags & PARTIAL_COMMUNITIES) - flags |= ATTR_PARTIAL; - - if (attr_writebuf(buf, flags, ATTR_LARGE_COMMUNITIES, NULL, - large_n * 12) == -1) - return -1; - - /* write out the communities */ - for (l = 0; l < comm->nentries; l++) - if ((uint8_t)comm->communities[l].flags == - COMMUNITY_TYPE_LARGE) { - uint32_t c; - c = htonl(comm->communities[l].data1); - if (ibuf_add(buf, &c, sizeof(c)) == -1) - return (-1); - c = htonl(comm->communities[l].data2); - if (ibuf_add(buf, &c, sizeof(c)) == -1) - return (-1); - c = htonl(comm->communities[l].data3); - if (ibuf_add(buf, &c, sizeof(c)) == -1) - return (-1); - } - } - return 0; } diff --git a/usr.sbin/bgpd/rde_prefix.c b/usr.sbin/bgpd/rde_prefix.c index 2466018fa..07cb8d53b 100644 --- a/usr.sbin/bgpd/rde_prefix.c +++ b/usr.sbin/bgpd/rde_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_prefix.c,v 1.49 2023/04/19 07:09:47 claudio Exp $ */ +/* $OpenBSD: rde_prefix.c,v 1.50 2023/07/12 14:45:43 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -468,143 +468,111 @@ pt_free(struct pt_entry *pte) /* dump a prefix into specified buffer */ int -pt_write(u_char *buf, int len, struct pt_entry *pte, int withdraw) +pt_writebuf(struct ibuf *buf, struct pt_entry *pte, int withdraw, + int add_path, uint32_t pathid) { struct pt_entry_vpn4 *pvpn4 = (struct pt_entry_vpn4 *)pte; struct pt_entry_vpn6 *pvpn6 = (struct pt_entry_vpn6 *)pte; struct pt_entry_flow *pflow = (struct pt_entry_flow *)pte; - int totlen, flowlen, psize; + struct ibuf *tmp; + int flowlen, psize; uint8_t plen; + if ((tmp = ibuf_dynamic(32, UINT16_MAX)) == NULL) + goto fail; + + if (add_path) { + if (ibuf_add_n32(tmp, pathid) == -1) + goto fail; + } + switch (pte->aid) { case AID_INET: case AID_INET6: plen = pte->prefixlen; - totlen = PREFIX_SIZE(plen); - - if (totlen > len) - return (-1); - *buf++ = plen; - memcpy(buf, pte->data, totlen - 1); - return (totlen); + if (ibuf_add_n8(tmp, plen) == -1) + goto fail; + if (ibuf_add(tmp, pte->data, PREFIX_SIZE(plen) - 1) == -1) + goto fail; + break; case AID_VPN_IPv4: plen = pvpn4->prefixlen; - totlen = PREFIX_SIZE(plen) + sizeof(pvpn4->rd); psize = PREFIX_SIZE(plen) - 1; plen += sizeof(pvpn4->rd) * 8; if (withdraw) { /* withdraw have one compat label as placeholder */ - totlen += 3; plen += 3 * 8; } else { - totlen += pvpn4->labellen; plen += pvpn4->labellen * 8; } - if (totlen > len) - return (-1); - *buf++ = plen; + if (ibuf_add_n8(tmp, plen) == -1) + goto fail; if (withdraw) { /* magic compatibility label as per rfc8277 */ - *buf++ = 0x80; - *buf++ = 0x0; - *buf++ = 0x0; + if (ibuf_add_n8(tmp, 0x80) == -1 || + ibuf_add_zero(tmp, 2) == -1) + goto fail; } else { - memcpy(buf, &pvpn4->labelstack, pvpn4->labellen); - buf += pvpn4->labellen; + if (ibuf_add(tmp, &pvpn4->labelstack, + pvpn4->labellen) == -1) + goto fail; } - memcpy(buf, &pvpn4->rd, sizeof(pvpn4->rd)); - buf += sizeof(pvpn4->rd); - memcpy(buf, &pvpn4->prefix4, psize); - return (totlen); + if (ibuf_add(tmp, &pvpn4->rd, sizeof(pvpn4->rd)) == -1 || + ibuf_add(tmp, &pvpn4->prefix4, psize) == -1) + goto fail; + break; case AID_VPN_IPv6: plen = pvpn6->prefixlen; - totlen = PREFIX_SIZE(plen) + sizeof(pvpn6->rd); psize = PREFIX_SIZE(plen) - 1; plen += sizeof(pvpn6->rd) * 8; if (withdraw) { /* withdraw have one compat label as placeholder */ - totlen += 3; plen += 3 * 8; } else { - totlen += pvpn6->labellen; plen += pvpn6->labellen * 8; } - if (totlen > len) - return (-1); - *buf++ = plen; + if (ibuf_add_n8(tmp, plen) == -1) + goto fail; if (withdraw) { /* magic compatibility label as per rfc8277 */ - *buf++ = 0x80; - *buf++ = 0x0; - *buf++ = 0x0; + if (ibuf_add_n8(tmp, 0x80) == -1 || + ibuf_add_zero(tmp, 2) == -1) + goto fail; } else { - memcpy(buf, &pvpn6->labelstack, pvpn6->labellen); - buf += pvpn6->labellen; + if (ibuf_add(tmp, &pvpn6->labelstack, + pvpn6->labellen) == -1) + goto fail; } - memcpy(buf, &pvpn6->rd, sizeof(pvpn6->rd)); - buf += sizeof(pvpn6->rd); - memcpy(buf, &pvpn6->prefix6, psize); - return (totlen); + if (ibuf_add(tmp, &pvpn6->rd, sizeof(pvpn6->rd)) == -1 || + ibuf_add(tmp, &pvpn6->prefix6, psize) == -1) + goto fail; + break; case AID_FLOWSPECv4: case AID_FLOWSPECv6: flowlen = pflow->len - PT_FLOW_SIZE; - totlen = flowlen < FLOWSPEC_LEN_LIMIT ? 1 : 2; - totlen += flowlen; - - if (totlen > len) - return (-1); - if (flowlen < FLOWSPEC_LEN_LIMIT) { - *buf++ = flowlen; + if (ibuf_add_n8(tmp, flowlen) == -1) + goto fail; } else { - *buf++ = 0xf0 | (flowlen >> 8); - *buf++ = flowlen & 0xff; + if (ibuf_add_n8(tmp, 0xf0 | (flowlen >> 8)) == -1 || + ibuf_add_n8(tmp, flowlen) == -1) + goto fail; } - memcpy(buf, &pflow->flow, flowlen); - return (totlen); - default: - return (-1); - } -} - -/* dump a prefix into specified ibuf, allocating space for it if needed */ -int -pt_writebuf(struct ibuf *buf, struct pt_entry *pte) -{ - struct pt_entry_vpn4 *pvpn4 = (struct pt_entry_vpn4 *)pte; - struct pt_entry_vpn6 *pvpn6 = (struct pt_entry_vpn6 *)pte; - struct pt_entry_flow *pflow = (struct pt_entry_flow *)pte; - int totlen, flowlen; - void *bptr; - - switch (pte->aid) { - case AID_INET: - case AID_INET6: - totlen = PREFIX_SIZE(pte->prefixlen); - break; - case AID_VPN_IPv4: - totlen = PREFIX_SIZE(pte->prefixlen) + sizeof(pvpn4->rd) + - pvpn4->labellen; - break; - case AID_VPN_IPv6: - totlen = PREFIX_SIZE(pte->prefixlen) + sizeof(pvpn6->rd) + - pvpn6->labellen; - break; - case AID_FLOWSPECv4: - case AID_FLOWSPECv6: - flowlen = pflow->len - PT_FLOW_SIZE; - totlen = flowlen < FLOWSPEC_LEN_LIMIT ? 1 : 2; - totlen += flowlen; + if (ibuf_add(tmp, &pflow->flow, flowlen) == -1) + goto fail; break; default: - return (-1); + goto fail; } - if ((bptr = ibuf_reserve(buf, totlen)) == NULL) - return (-1); - if (pt_write(bptr, totlen, pte, 0) == -1) - return (-1); - return (0); + if (ibuf_add_buf(buf, tmp) == -1) + goto fail; + ibuf_free(tmp); + return 0; + + fail: + ibuf_free(tmp); + return -1; } diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index f4f993eaf..70d3fa27d 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.162 2023/04/19 08:30:37 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.163 2023/07/12 14:45:43 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker @@ -558,17 +558,15 @@ up_prep_adjout(struct rde_peer *peer, struct filterstate *state, uint8_t aid) static int -up_generate_attr(u_char *buf, int len, struct rde_peer *peer, - struct filterstate *state, uint8_t aid) +up_generate_attr(struct ibuf *buf, struct rde_peer *peer, + struct rde_aspath *asp, struct rde_community *comm, struct nexthop *nh, + uint8_t aid) { - struct rde_aspath *asp = &state->aspath; - struct rde_community *comm = &state->communities; struct attr *oa = NULL, *newaggr = NULL; u_char *pdata; uint32_t tmp32; - struct bgpd_addr *nexthop; - int flags, r, neednewpath = 0; - uint16_t wlen = 0, plen; + int flags, neednewpath = 0, rv; + uint16_t plen; uint8_t oalen = 0, type; if (asp->others_len > 0) @@ -576,8 +574,6 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, /* dump attributes in ascending order */ for (type = ATTR_ORIGIN; type < 255; type++) { - r = 0; - while (oa && oa->type < type) { if (oalen < asp->others_len) oa = asp->others[oalen++]; @@ -590,9 +586,9 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, * Attributes stored in rde_aspath */ case ATTR_ORIGIN: - if ((r = attr_write(buf + wlen, len, ATTR_WELL_KNOWN, - ATTR_ORIGIN, &asp->origin, 1)) == -1) - return (-1); + if (attr_writebuf(buf, ATTR_WELL_KNOWN, + ATTR_ORIGIN, &asp->origin, 1) == -1) + return -1; break; case ATTR_ASPATH: plen = aspath_length(asp->aspath); @@ -601,21 +597,21 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, if (!peer_has_as4byte(peer)) pdata = aspath_deflate(pdata, &plen, &neednewpath); - - if ((r = attr_write(buf + wlen, len, ATTR_WELL_KNOWN, - ATTR_ASPATH, pdata, plen)) == -1) - return (-1); + rv = attr_writebuf(buf, ATTR_WELL_KNOWN, + ATTR_ASPATH, pdata, plen); if (!peer_has_as4byte(peer)) free(pdata); + + if (rv == -1) + return -1; break; case ATTR_NEXTHOP: switch (aid) { case AID_INET: - nexthop = &state->nexthop->exit_nexthop; - if ((r = attr_write(buf + wlen, len, - ATTR_WELL_KNOWN, ATTR_NEXTHOP, - &nexthop->v4.s_addr, 4)) == -1) - return (-1); + if (attr_writebuf(buf, ATTR_WELL_KNOWN, + ATTR_NEXTHOP, &nh->exit_nexthop.v4, + sizeof(nh->exit_nexthop.v4)) == -1) + return -1; break; default: break; @@ -632,37 +628,29 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, asp->flags & F_ATTR_MED_ANNOUNCE || peer->flags & PEERFLAG_TRANS_AS)) { tmp32 = htonl(asp->med); - if ((r = attr_write(buf + wlen, len, - ATTR_OPTIONAL, ATTR_MED, &tmp32, 4)) == -1) - return (-1); + if (attr_writebuf(buf, ATTR_OPTIONAL, + ATTR_MED, &tmp32, 4) == -1) + return -1; } break; case ATTR_LOCALPREF: if (!peer->conf.ebgp) { /* local preference, only valid for ibgp */ tmp32 = htonl(asp->lpref); - if ((r = attr_write(buf + wlen, len, - ATTR_WELL_KNOWN, ATTR_LOCALPREF, &tmp32, - 4)) == -1) - return (-1); + if (attr_writebuf(buf, ATTR_WELL_KNOWN, + ATTR_LOCALPREF, &tmp32, 4) == -1) + return -1; } break; /* * Communities are stored in struct rde_community */ case ATTR_COMMUNITIES: - if ((r = community_write(comm, buf + wlen, len)) == -1) - return (-1); - break; case ATTR_EXT_COMMUNITIES: - if ((r = community_ext_write(comm, peer->conf.ebgp, - buf + wlen, len)) == -1) - return (-1); - break; case ATTR_LARGE_COMMUNITIES: - if ((r = community_large_write(comm, buf + wlen, - len)) == -1) - return (-1); + if (community_writebuf(comm, type, peer->conf.ebgp, + buf) == -1) + return -1; break; /* * NEW to OLD conversion when sending stuff to a 2byte AS peer @@ -675,11 +663,10 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, flags = ATTR_OPTIONAL|ATTR_TRANSITIVE; if (!(asp->flags & F_PREFIX_ANNOUNCED)) flags |= ATTR_PARTIAL; - if (plen == 0) - r = 0; - else if ((r = attr_write(buf + wlen, len, flags, - ATTR_AS4_PATH, pdata, plen)) == -1) - return (-1); + if (plen != 0) + if (attr_writebuf(buf, flags, + ATTR_AS4_PATH, pdata, plen) == -1) + return -1; } break; case ATTR_AS4_AGGREGATOR: @@ -687,10 +674,10 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, flags = ATTR_OPTIONAL|ATTR_TRANSITIVE; if (!(asp->flags & F_PREFIX_ANNOUNCED)) flags |= ATTR_PARTIAL; - if ((r = attr_write(buf + wlen, len, flags, + if (attr_writebuf(buf, flags, ATTR_AS4_AGGREGATOR, newaggr->data, - newaggr->len)) == -1) - return (-1); + newaggr->len) == -1) + return -1; } break; /* @@ -712,24 +699,24 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, case ATTR_ATOMIC_AGGREGATE: if (oa == NULL || oa->type != type) break; - if ((r = attr_write(buf + wlen, len, - ATTR_WELL_KNOWN, ATTR_ATOMIC_AGGREGATE, - NULL, 0)) == -1) - return (-1); + if (attr_writebuf(buf, ATTR_WELL_KNOWN, + ATTR_ATOMIC_AGGREGATE, NULL, 0) == -1) + return -1; break; case ATTR_AGGREGATOR: if (oa == NULL || oa->type != type) break; + if ((!(oa->flags & ATTR_TRANSITIVE)) && + peer->conf.ebgp) + break; if (!peer_has_as4byte(peer)) { /* need to deflate the aggregator */ - uint8_t t[6]; + uint8_t t[6]; uint16_t tas; if ((!(oa->flags & ATTR_TRANSITIVE)) && - peer->conf.ebgp) { - r = 0; + peer->conf.ebgp) break; - } memcpy(&tmp32, oa->data, sizeof(tmp32)); if (ntohl(tmp32) > USHRT_MAX) { @@ -742,30 +729,31 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, memcpy(t + sizeof(tas), oa->data + sizeof(tmp32), oa->len - sizeof(tmp32)); - if ((r = attr_write(buf + wlen, len, - oa->flags, oa->type, &t, sizeof(t))) == -1) - return (-1); - break; + if (attr_writebuf(buf, oa->flags, + oa->type, &t, sizeof(t)) == -1) + return -1; + } else { + if (attr_writebuf(buf, oa->flags, oa->type, + oa->data, oa->len) == -1) + return -1; } - /* FALLTHROUGH */ + break; case ATTR_ORIGINATOR_ID: case ATTR_CLUSTER_LIST: case ATTR_OTC: if (oa == NULL || oa->type != type) break; if ((!(oa->flags & ATTR_TRANSITIVE)) && - peer->conf.ebgp) { - r = 0; + peer->conf.ebgp) break; - } - if ((r = attr_write(buf + wlen, len, - oa->flags, oa->type, oa->data, oa->len)) == -1) - return (-1); + if (attr_writebuf(buf, oa->flags, oa->type, + oa->data, oa->len) == -1) + return -1; break; default: if (oa == NULL && type >= ATTR_FIRST_UNKNOWN) /* there is no attribute left to dump */ - goto done; + return (0); if (oa == NULL || oa->type != type) break; @@ -779,16 +767,12 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, */ break; } - if ((r = attr_write(buf + wlen, len, - oa->flags | ATTR_PARTIAL, oa->type, - oa->data, oa->len)) == -1) - return (-1); + if (attr_writebuf(buf, oa->flags | ATTR_PARTIAL, + oa->type, oa->data, oa->len) == -1) + return -1; } - wlen += r; - len -= r; } -done: - return (wlen); + return 0; } /* @@ -817,33 +801,42 @@ up_is_eor(struct rde_peer *peer, uint8_t aid) /* minimal buffer size > withdraw len + attr len + attr hdr + afi/safi */ #define MIN_UPDATE_LEN 16 +static void +up_prefix_free(struct prefix_tree *prefix_head, struct prefix *p, + struct rde_peer *peer, int withdraw) +{ + if (withdraw) { + /* prefix no longer needed, remove it */ + prefix_adjout_destroy(p); + peer->stats.prefix_sent_withdraw++; + } else { + /* prefix still in Adj-RIB-Out, keep it */ + RB_REMOVE(prefix_tree, prefix_head, p); + p->flags &= ~PREFIX_FLAG_UPDATE; + peer->stats.pending_update--; + peer->stats.prefix_sent_update++; + } +} + /* * Write prefixes to buffer until either there is no more space or * the next prefix has no longer the same ASPATH attributes. + * Returns -1 if no prefix was written else 0. */ static int -up_dump_prefix(u_char *buf, int len, struct prefix_tree *prefix_head, +up_dump_prefix(struct ibuf *buf, struct prefix_tree *prefix_head, struct rde_peer *peer, int withdraw) { struct prefix *p, *np; - uint32_t pathid; - int r, wpos = 0, done = 0; + int done = 0, has_ap = -1, rv = -1; RB_FOREACH_SAFE(p, prefix_tree, prefix_head, np) { - if (peer_has_add_path(peer, p->pt->aid, CAPA_AP_SEND)) { - if (len <= wpos + (int)sizeof(pathid)) - break; - pathid = htonl(p->path_id_tx); - memcpy(buf + wpos, &pathid, sizeof(pathid)); - wpos += sizeof(pathid); - } - if ((r = pt_write(buf + wpos, len - wpos, p->pt, - withdraw)) == -1) { - if (peer_has_add_path(peer, p->pt->aid, CAPA_AP_SEND)) - wpos -= sizeof(pathid); + if (has_ap == -1) + has_ap = peer_has_add_path(peer, p->pt->aid, + CAPA_AP_SEND); + if (pt_writebuf(buf, p->pt, withdraw, has_ap, p->path_id_tx) == + -1) break; - } - wpos += r; /* make sure we only dump prefixes which belong together */ if (np == NULL || @@ -854,276 +847,249 @@ up_dump_prefix(u_char *buf, int len, struct prefix_tree *prefix_head, (np->flags & PREFIX_FLAG_EOR)) done = 1; - if (withdraw) { - /* prefix no longer needed, remove it */ - prefix_adjout_destroy(p); - peer->stats.prefix_sent_withdraw++; - } else { - /* prefix still in Adj-RIB-Out, keep it */ - RB_REMOVE(prefix_tree, prefix_head, p); - p->flags &= ~PREFIX_FLAG_UPDATE; - peer->stats.pending_update--; - peer->stats.prefix_sent_update++; - } - + rv = 0; + up_prefix_free(prefix_head, p, peer, withdraw); if (done) break; } - return (wpos); -} - -int -up_dump_withdraws(u_char *buf, int len, struct rde_peer *peer, uint8_t aid) -{ - uint16_t wpos, wd_len; - int r; - - if (len < MIN_UPDATE_LEN) - return (-1); - - /* reserve space for the length field */ - wpos = 2; - r = up_dump_prefix(buf + wpos, len - wpos, &peer->withdraws[aid], - peer, 1); - wd_len = htons(r); - memcpy(buf, &wd_len, 2); - - return (wpos + r); -} - -int -up_dump_mp_unreach(u_char *buf, int len, struct rde_peer *peer, uint8_t aid) -{ - u_char *attrbuf; - int wpos, r; - uint16_t attr_len, tmp; - - if (len < MIN_UPDATE_LEN || RB_EMPTY(&peer->withdraws[aid])) - return (-1); - - /* reserve space for withdraw len, attr len */ - wpos = 2 + 2; - attrbuf = buf + wpos; - - /* attribute header, defaulting to extended length one */ - attrbuf[0] = ATTR_OPTIONAL | ATTR_EXTLEN; - attrbuf[1] = ATTR_MP_UNREACH_NLRI; - wpos += 4; - - /* afi & safi */ - if (aid2afi(aid, &tmp, buf + wpos + 2)) - fatalx("up_dump_mp_unreach: bad AID"); - tmp = htons(tmp); - memcpy(buf + wpos, &tmp, sizeof(uint16_t)); - wpos += 3; - - r = up_dump_prefix(buf + wpos, len - wpos, &peer->withdraws[aid], - peer, 1); - if (r == 0) - return (-1); - wpos += r; - attr_len = r + 3; /* prefixes + afi & safi */ - - /* attribute length */ - attr_len = htons(attr_len); - memcpy(attrbuf + 2, &attr_len, sizeof(attr_len)); - - /* write length fields */ - memset(buf, 0, sizeof(uint16_t)); /* withdrawn routes len */ - attr_len = htons(wpos - 4); - memcpy(buf + 2, &attr_len, sizeof(attr_len)); - - return (wpos); -} - -int -up_dump_attrnlri(u_char *buf, int len, struct rde_peer *peer) -{ - struct filterstate state; - struct prefix *p; - int r, wpos; - uint16_t attr_len; - - if (len < 2) - fatalx("up_dump_attrnlri: buffer way too small"); - if (len < MIN_UPDATE_LEN) - goto done; - - p = RB_MIN(prefix_tree, &peer->updates[AID_INET]); - if (p == NULL) - goto done; - - rde_filterstate_prep(&state, p); - r = up_generate_attr(buf + 2, len - 2, peer, &state, AID_INET); - rde_filterstate_clean(&state); - if (r == -1) { - /* - * either no packet or not enough space. - * The length field needs to be set to zero else it would be - * an invalid bgp update. - */ -done: - memset(buf, 0, 2); - return (2); - } - - /* first dump the 2-byte path attribute length */ - attr_len = htons(r); - memcpy(buf, &attr_len, 2); - wpos = 2; - /* then skip over the already dumped path attributes themselves */ - wpos += r; - - /* last but not least dump the nlri */ - r = up_dump_prefix(buf + wpos, len - wpos, &peer->updates[AID_INET], - peer, 0); - wpos += r; - - return (wpos); + return rv; } static int -up_generate_mp_reach(u_char *buf, int len, struct rde_peer *peer, - struct filterstate *state, uint8_t aid) +up_generate_mp_reach(struct ibuf *buf, struct rde_peer *peer, + struct nexthop *nh, uint8_t aid) { - struct bgpd_addr *nexthop; - u_char *attrbuf; - int r, wpos, attrlen; - uint16_t tmp; + struct bgpd_addr *nexthop; + size_t off; + uint16_t len, afi; + uint8_t safi; - if (len < 4) - return (-1); /* attribute header, defaulting to extended length one */ - buf[0] = ATTR_OPTIONAL | ATTR_EXTLEN; - buf[1] = ATTR_MP_REACH_NLRI; - wpos = 4; - attrbuf = buf + wpos; + if (ibuf_add_n8(buf, ATTR_OPTIONAL | ATTR_EXTLEN) == -1) + return -1; + if (ibuf_add_n8(buf, ATTR_MP_REACH_NLRI) == -1) + return -1; + off = ibuf_size(buf); + if (ibuf_add_zero(buf, sizeof(len)) == -1) + return -1; + + if (aid2afi(aid, &afi, &safi)) + fatalx("up_generate_mp_reach: bad AID"); + + /* AFI + SAFI + NH LEN + NH + Reserved */ + if (ibuf_add_n16(buf, afi) == -1) + return -1; + if (ibuf_add_n8(buf, safi) == -1) + return -1; switch (aid) { case AID_INET6: - attrlen = 21; /* AFI + SAFI + NH LEN + NH + Reserved */ - if (len < wpos + attrlen) - return (-1); - wpos += attrlen; - if (aid2afi(aid, &tmp, &attrbuf[2])) - fatalx("up_generate_mp_reach: bad AID"); - tmp = htons(tmp); - memcpy(attrbuf, &tmp, sizeof(tmp)); - attrbuf[3] = sizeof(struct in6_addr); - attrbuf[20] = 0; /* Reserved must be 0 */ - + /* NH LEN */ + if (ibuf_add_n8(buf, sizeof(struct in6_addr)) == -1) + return -1; /* write nexthop */ - attrbuf += 4; - nexthop = &state->nexthop->exit_nexthop; - memcpy(attrbuf, &nexthop->v6, sizeof(struct in6_addr)); + nexthop = &nh->exit_nexthop; + if (ibuf_add(buf, &nexthop->v6, sizeof(struct in6_addr)) == -1) + return -1; break; case AID_VPN_IPv4: - attrlen = 17; /* AFI + SAFI + NH LEN + NH + Reserved */ - if (len < wpos + attrlen) - return (-1); - wpos += attrlen; - if (aid2afi(aid, &tmp, &attrbuf[2])) - fatalx("up_generate_mp_reachi: bad AID"); - tmp = htons(tmp); - memcpy(attrbuf, &tmp, sizeof(tmp)); - attrbuf[3] = sizeof(uint64_t) + sizeof(struct in_addr); - memset(attrbuf + 4, 0, sizeof(uint64_t)); - attrbuf[16] = 0; /* Reserved must be 0 */ - + /* NH LEN */ + if (ibuf_add_n8(buf, + sizeof(uint64_t) + sizeof(struct in_addr)) == -1) + return -1; + /* write zero rd */ + if (ibuf_add_zero(buf, sizeof(uint64_t)) == -1) + return -1; /* write nexthop */ - attrbuf += 12; - nexthop = &state->nexthop->exit_nexthop; - memcpy(attrbuf, &nexthop->v4, sizeof(struct in_addr)); + nexthop = &nh->exit_nexthop; + if (ibuf_add(buf, &nexthop->v4, sizeof(struct in_addr)) == -1) + return -1; break; case AID_VPN_IPv6: - attrlen = 29; /* AFI + SAFI + NH LEN + NH + Reserved */ - if (len < wpos + attrlen) - return (-1); - wpos += attrlen; - if (aid2afi(aid, &tmp, &attrbuf[2])) - fatalx("up_generate_mp_reachi: bad AID"); - tmp = htons(tmp); - memcpy(attrbuf, &tmp, sizeof(tmp)); - attrbuf[3] = sizeof(uint64_t) + sizeof(struct in6_addr); - memset(attrbuf + 4, 0, sizeof(uint64_t)); - attrbuf[28] = 0; /* Reserved must be 0 */ - + /* NH LEN */ + if (ibuf_add_n8(buf, + sizeof(uint64_t) + sizeof(struct in6_addr)) == -1) + return -1; + /* write zero rd */ + if (ibuf_add_zero(buf, sizeof(uint64_t)) == -1) + return -1; /* write nexthop */ - attrbuf += 12; - nexthop = &state->nexthop->exit_nexthop; - memcpy(attrbuf, &nexthop->v6, sizeof(struct in6_addr)); + nexthop = &nh->exit_nexthop; + if (ibuf_add(buf, &nexthop->v6, sizeof(struct in6_addr)) == -1) + return -1; break; case AID_FLOWSPECv4: case AID_FLOWSPECv6: - attrlen = 5; /* AFI + SAFI + NH LEN + NH + Reserved */ - if (len < wpos + attrlen) - return (-1); - wpos += attrlen; - if (aid2afi(aid, &tmp, &attrbuf[2])) - fatalx("up_generate_mp_reachi: bad AID"); - tmp = htons(tmp); - memcpy(attrbuf, &tmp, sizeof(tmp)); - attrbuf[3] = 0; /* nh len MUST be 0 */ - attrbuf[4] = 0; /* Reserved must be 0 */ + if (ibuf_add_zero(buf, 1) == -1) /* NH LEN MUST be 0 */ + return -1; + /* no NH */ break; default: fatalx("up_generate_mp_reach: unknown AID"); } - r = up_dump_prefix(buf + wpos, len - wpos, &peer->updates[aid], - peer, 0); - if (r == 0) { - /* no prefixes written ... */ - return (-1); - } - attrlen += r; - wpos += r; - /* update attribute length field */ - tmp = htons(attrlen); - memcpy(buf + 2, &tmp, sizeof(tmp)); + if (ibuf_add_zero(buf, 1) == -1) /* Reserved must be 0 */ + return -1; - return (wpos); + if (up_dump_prefix(buf, &peer->updates[aid], peer, 0) == -1) + /* no prefixes written, fail update */ + return (-1); + + /* update MP_REACH attribute length field */ + len = ibuf_size(buf) - off - sizeof(len); + if (ibuf_set_n16(buf, off, len) == -1) + return -1; + + return 0; } +/* + * Generate UPDATE message containing either just withdraws or updates. + * UPDATE messages are contructed like this: + * + * +-----------------------------------------------------+ + * | Withdrawn Routes Length (2 octets) | + * +-----------------------------------------------------+ + * | Withdrawn Routes (variable) | + * +-----------------------------------------------------+ + * | Total Path Attribute Length (2 octets) | + * +-----------------------------------------------------+ + * | Path Attributes (variable) | + * +-----------------------------------------------------+ + * | Network Layer Reachability Information (variable) | + * +-----------------------------------------------------+ + * + * Multiprotocol messages use MP_REACH_NLRI and MP_UNREACH_NLRI + * the latter will be the only path attribute in a message. + */ + +/* + * Write UPDATE message for withdrawn routes. The size of buf limits + * how may routes can be added. Return 0 on success -1 on error which + * includes generating an empty withdraw message. + */ int -up_dump_mp_reach(u_char *buf, int len, struct rde_peer *peer, uint8_t aid) +up_dump_withdraws(struct ibuf *buf, struct rde_peer *peer, uint8_t aid) { - struct filterstate state; - struct prefix *p; - int r, wpos; - uint16_t attr_len; + size_t off; + uint16_t afi, len; + uint8_t safi; - if (len < MIN_UPDATE_LEN) - return 0; + /* reserve space for the withdrawn routes length field */ + off = ibuf_size(buf); + if (ibuf_add_zero(buf, sizeof(len)) == -1) + return -1; + + if (aid != AID_INET) { + /* reserve space for 2-byte path attribute length */ + off = ibuf_size(buf); + if (ibuf_add_zero(buf, sizeof(len)) == -1) + return -1; + + /* attribute header, defaulting to extended length one */ + if (ibuf_add_n8(buf, ATTR_OPTIONAL | ATTR_EXTLEN) == -1) + return -1; + if (ibuf_add_n8(buf, ATTR_MP_UNREACH_NLRI) == -1) + return -1; + if (ibuf_add_zero(buf, sizeof(len)) == -1) + return -1; + + /* afi & safi */ + if (aid2afi(aid, &afi, &safi)) + fatalx("up_dump_mp_unreach: bad AID"); + if (ibuf_add_n16(buf, afi) == -1) + return -1; + if (ibuf_add_n8(buf, safi) == -1) + return -1; + } + + if (up_dump_prefix(buf, &peer->withdraws[aid], peer, 1) == -1) + return -1; + + /* update length field (either withdrawn routes or attribute length) */ + len = ibuf_size(buf) - off - sizeof(len); + if (ibuf_set_n16(buf, off, len) == -1) + return -1; + + if (aid != AID_INET) { + /* write MP_UNREACH_NLRI attribute length (always extended) */ + len -= 4; /* skip attribute header */ + if (ibuf_set_n16(buf, off + sizeof(len) + 2, len) == -1) + return -1; + } else { + /* no extra attributes so set attribute len to 0 */ + if (ibuf_add_zero(buf, sizeof(len)) == -1) + return -1; + } + + return 0; +} + +/* + * Write UPDATE message for changed and added routes. The size of buf limits + * how may routes can be added. The function first dumps the path attributes + * and then tries to add as many prefixes using these attributes. + * Return 0 on success -1 on error which includes producing an empty message. + */ +int +up_dump_update(struct ibuf *buf, struct rde_peer *peer, uint8_t aid) +{ + struct bgpd_addr addr; + struct prefix *p; + size_t off; + uint16_t len; - /* get starting point */ p = RB_MIN(prefix_tree, &peer->updates[aid]); if (p == NULL) - return 0; + return -1; - wpos = 4; /* reserve space for length fields */ + /* withdrawn routes length field is 0 */ + if (ibuf_add_zero(buf, sizeof(len)) == -1) + return -1; - rde_filterstate_prep(&state, p); + /* reserve space for 2-byte path attribute length */ + off = ibuf_size(buf); + if (ibuf_add_zero(buf, sizeof(len)) == -1) + return -1; - /* write regular path attributes */ - r = up_generate_attr(buf + wpos, len - wpos, peer, &state, aid); - if (r == -1) { - rde_filterstate_clean(&state); - return 0; + if (up_generate_attr(buf, peer, prefix_aspath(p), + prefix_communities(p), prefix_nexthop(p), aid) == -1) + goto fail; + + if (aid != AID_INET) { + /* write mp attribute including nlri */ + + /* + * RFC 7606 wants this to be first but then we need + * to use multiple buffers with adjusted length to + * merge the attributes together in reverse order of + * creation. + */ + if (up_generate_mp_reach(buf, peer, prefix_nexthop(p), aid) == + -1) + goto fail; } - wpos += r; - /* write mp attribute */ - r = up_generate_mp_reach(buf + wpos, len - wpos, peer, &state, aid); - rde_filterstate_clean(&state); - if (r == -1) - return 0; - wpos += r; + /* update attribute length field */ + len = ibuf_size(buf) - off - sizeof(len); + if (ibuf_set_n16(buf, off, len) == -1) + return -1; - /* write length fields */ - memset(buf, 0, sizeof(uint16_t)); /* withdrawn routes len */ - attr_len = htons(wpos - 4); - memcpy(buf + 2, &attr_len, sizeof(attr_len)); + if (aid == AID_INET) { + /* last but not least dump the IPv4 nlri */ + if (up_dump_prefix(buf, &peer->updates[aid], peer, 0) == -1) + goto fail; + } - return (wpos); + return 0; + +fail: + /* Not enough space. Drop prefix, it will never fit. */ + pt_getaddr(p->pt, &addr); + log_peer_warnx(&peer->conf, "path attributes to large, " + "prefix %s/%d dropped", log_addr(&addr), p->pt->prefixlen); + + up_prefix_free(&peer->updates[AID_INET], p, peer, 0); + /* XXX should probably send a withdraw for this prefix */ + return -1; } diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 543b6bfed..3b5fa3b52 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.445 2023/05/25 14:20:25 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.446 2023/07/12 14:45:43 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -1383,7 +1383,7 @@ session_sendmsg(struct bgp_msg *msg, struct peer *p) if ((mrt->peer_id == 0 && mrt->group_id == 0) || mrt->peer_id == p->conf.id || (mrt->group_id != 0 && mrt->group_id == p->conf.groupid)) - mrt_dump_bgp_msg(mrt, msg->buf->buf, msg->len, p, + mrt_dump_bgp_msg(mrt, ibuf_data(msg->buf), msg->len, p, msg->type); } @@ -1589,7 +1589,7 @@ session_open(struct peer *p) uint8_t op_len = optparamlen; errs += ibuf_add(buf->buf, &op_len, 1); } - errs += ibuf_add(buf->buf, opb->buf, ibuf_size(opb)); + errs += ibuf_add_buf(buf->buf, opb); } ibuf_free(opb); diff --git a/usr.sbin/bgpd/version.h b/usr.sbin/bgpd/version.h index c219d1875..d106917fa 100644 --- a/usr.sbin/bgpd/version.h +++ b/usr.sbin/bgpd/version.h @@ -1,3 +1,3 @@ -/* $OpenBSD: version.h,v 1.11 2023/05/01 19:44:42 claudio Exp $ */ +/* $OpenBSD: version.h,v 1.12 2023/07/11 15:18:31 claudio Exp $ */ -#define BGPD_VERSION "8.0" +#define BGPD_VERSION "8.1" diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 2ac23e7f0..536085410 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.58 2023/06/13 15:36:21 millert Exp $ */ +/* $OpenBSD: entry.c,v 1.59 2023/07/19 21:26:02 millert Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -275,18 +275,17 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, goto eof; } - /* ch is the first character of a command, or a username */ - unget_char(ch, file); - if (!pw) { char *username = cmd; /* temp buffer */ + unget_char(ch, file); ch = get_string(username, MAX_COMMAND, file, " \t\n"); if (ch == EOF || ch == '\n' || ch == '*') { ecode = e_cmd; goto eof; } + Skip_Blanks(ch, file) pw = getpwnam(username); if (pw == NULL) { @@ -356,7 +355,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, /* An optional series of '-'-prefixed flags in getopt style can * occur before the command. */ - ch = get_char(file); while (ch == '-') { int flags = 0, loop = 1; diff --git a/usr.sbin/dhcrelay6/dispatch.c b/usr.sbin/dhcrelay6/dispatch.c index 06aba339e..0b9ea2353 100644 --- a/usr.sbin/dhcrelay6/dispatch.c +++ b/usr.sbin/dhcrelay6/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.2 2021/01/17 13:41:24 claudio Exp $ */ +/* $OpenBSD: dispatch.c,v 1.3 2023/07/14 07:09:00 gerhard Exp $ */ /* * Copyright 2004 Henning Brauer @@ -168,7 +168,8 @@ setup_iflist(void) /* Skip non ethernet interfaces. */ if (ifi->ifi_type != IFT_ETHER && - ifi->ifi_type != IFT_ENC) { + ifi->ifi_type != IFT_ENC && + ifi->ifi_type != IFT_CARP) { TAILQ_REMOVE(&intflist, intf, entry); free(intf); continue; diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 43770283b..6ed6c36d5 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.162 2022/10/24 15:02:01 jmc Exp $ */ +/* $OpenBSD: httpd.h,v 1.163 2023/07/12 12:37:27 tb Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -45,7 +45,7 @@ #define CONF_FILE "/etc/httpd.conf" #define HTTPD_USER "www" -#define HTTPD_SERVERNAME "Windows 3.11" +#define HTTPD_SERVERNAME "Tezcatlipoca" #define HTTPD_DOCROOT "/htdocs" #define HTTPD_ERRDOCTEMPLATE "err" /* 3-char name */ #define HTTPD_ERRDOCROOT_MAX (PATH_MAX - sizeof("000.html")) @@ -352,6 +352,7 @@ struct client { int clt_inflight; struct range_data clt_ranges; struct fcgi_data clt_fcgi; + const char *clt_fcgi_error; char *clt_remote_user; struct evbuffer *clt_srvevb; diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index 90a47d67c..6999b08cf 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.126 2021/07/14 13:33:57 kn Exp $ */ +/* $OpenBSD: server.c,v 1.127 2023/07/12 12:37:27 tb Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -1300,6 +1300,11 @@ server_close(struct client *clt, const char *msg) { struct server *srv = clt->clt_srv; + if (clt->clt_fcgi_error != NULL) { + clt->clt_fcgi_error = msg; + return; + } + SPLAY_REMOVE(client_tree, &srv->srv_clients, clt); /* free the HTTP descriptors incl. headers */ diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c index 073ab3440..d2c7d8a20 100644 --- a/usr.sbin/httpd/server_fcgi.c +++ b/usr.sbin/httpd/server_fcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_fcgi.c,v 1.95 2022/08/15 12:29:17 claudio Exp $ */ +/* $OpenBSD: server_fcgi.c,v 1.96 2023/07/12 12:37:28 tb Exp $ */ /* * Copyright (c) 2014 Florian Obser @@ -372,7 +372,18 @@ server_fcgi(struct httpd *env, struct client *clt) srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec); bufferevent_enable(clt->clt_srvbev, EV_READ|EV_WRITE); if (clt->clt_toread != 0) { + /* + * XXX - Work around UAF: server_read_httpcontent() can call + * server_close(), normally freeing clt. If clt->clt_fcgi_error + * changed, call server_close() via server_abort_http(). + */ + clt->clt_fcgi_error = ""; server_read_httpcontent(clt->clt_bev, clt); + errstr = clt->clt_fcgi_error; + clt->clt_fcgi_error = NULL; + if (errstr[0] != '\0') + goto fail; + errstr = NULL; bufferevent_enable(clt->clt_bev, EV_READ); } else { bufferevent_disable(clt->clt_bev, EV_READ); diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index 26bfb2122..25747698c 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCreate.pm,v 1.194 2023/07/04 14:03:16 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.195 2023/07/20 17:56:37 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -594,7 +594,7 @@ sub makesum_plist($self, $state, $plist) my $fname = $self->fullname; for (my $i = 1; ; $i++) { if (-e "$state->{base}/$fname-$i") { - my $e = OpenBSD::PackingElement::File->add($plist, + my $e = OpenBSD::PackingElement::File->add($plist, $self->name."-".$i); $e->compute_checksum($e, $state, $state->{base}); } else { @@ -773,7 +773,7 @@ sub check_version($self, $state, $unsubst) if (defined $l[0]) { if (!$unsubst =~ m/\$\{LIB$l[0]_VERSION\}/) { $state->error( - "Incorrectly versioned shared library: #1", + "Incorrectly versioned shared library: #1", $unsubst); } } else { @@ -1571,6 +1571,14 @@ sub validate_pkgname($self, $state, $pkgname) } my $okay_flavors = {map {($_, 1)} split(/\s+/, $flavor_list) }; my $v = OpenBSD::PackageName->from_string($pkgname); + + # first check we got a non buggy pkgname, since otherwise + # the parts we test won't even exist ! + if ($v->has_issues) { + $state->errsay("Error FULLPKGNAME #1 #2", $pkgname, + $v->has_issues); + $state->fatal("Can't continue"); + } my $errors = 0; if ($v->{version}->p != $revision) { $state->errsay("REVISION mismatch (REVISION=#1)", $revision); diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh index fb87943ba..eda191fae 100644 --- a/usr.sbin/rcctl/rcctl.sh +++ b/usr.sbin/rcctl/rcctl.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: rcctl.sh,v 1.116 2023/04/24 14:31:15 kn Exp $ +# $OpenBSD: rcctl.sh,v 1.117 2023/07/13 13:54:27 ajacoutot Exp $ # # Copyright (c) 2014, 2015-2022 Antoine Jacoutot # Copyright (c) 2014 Ingo Schwarze @@ -535,13 +535,17 @@ case ${action} in shift 1 svcs="$*" [ -z "${svcs}" ] && usage - # it's ok to disable a non-existing daemon - if [ "${action}" != "disable" ]; then - for svc in ${svcs}; do + for svc in ${svcs}; do + # it's ok to disable a non-existing daemon + if [ "${action}" != "disable" ]; then svc_is_avail ${svc} || \ rcctl_err "service ${svc} does not exist" 2 - done - fi + # but still check for bad input + else + _rc_check_name "${svc}" || \ + rcctl_err "service ${svc} does not exist" 2 + fi + done ;; get|getdef) svc=$2 @@ -572,6 +576,10 @@ case ${action} in if [ "${action} ${var} ${args}" != "set status off" ]; then svc_is_avail ${svc} || \ rcctl_err "service ${svc} does not exist" 2 + # but still check for bad input + else + _rc_check_name "${svc}" || \ + rcctl_err "service ${svc} does not exist" 2 fi [[ ${var} != @(class|execdir|flags|logger|rtable|status|timeout|user) ]] && usage svc_is_meta ${svc} && [ "${var}" != "status" ] && \ diff --git a/usr.sbin/relayd/ca.c b/usr.sbin/relayd/ca.c index 2c5f7b6ce..ea57b93e3 100644 --- a/usr.sbin/relayd/ca.c +++ b/usr.sbin/relayd/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.42 2023/06/11 10:30:26 op Exp $ */ +/* $OpenBSD: ca.c,v 1.43 2023/07/16 09:23:33 tb Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -41,20 +41,8 @@ void ca_launch(void); int ca_dispatch_parent(int, struct privsep_proc *, struct imsg *); int ca_dispatch_relay(int, struct privsep_proc *, struct imsg *); -int rsae_pub_enc(int, const u_char *, u_char *, RSA *, int); -int rsae_pub_dec(int,const u_char *, u_char *, RSA *, int); int rsae_priv_enc(int, const u_char *, u_char *, RSA *, int); int rsae_priv_dec(int, const u_char *, u_char *, RSA *, int); -int rsae_mod_exp(BIGNUM *, const BIGNUM *, RSA *, BN_CTX *); -int rsae_bn_mod_exp(BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, BN_CTX *, BN_MONT_CTX *); -int rsae_init(RSA *); -int rsae_finish(RSA *); -int rsae_sign(int, const u_char *, u_int, u_char *, u_int *, - const RSA *); -int rsae_verify(int dtype, const u_char *m, u_int, const u_char *, - u_int, const RSA *); -int rsae_keygen(RSA *, int, BIGNUM *, BN_GENCB *); static struct relayd *env = NULL; @@ -301,7 +289,7 @@ ca_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg) * RSA privsep engine (called from unprivileged processes) */ -const RSA_METHOD *rsa_default = NULL; +static const RSA_METHOD *rsa_default; static RSA_METHOD *rsae_method; static int @@ -416,20 +404,6 @@ rsae_send_imsg(int flen, const u_char *from, u_char *to, RSA *rsa, return ret; } -int -rsae_pub_enc(int flen,const u_char *from, u_char *to, RSA *rsa,int padding) -{ - DPRINTF("%s:%d", __func__, __LINE__); - return RSA_meth_get_pub_enc(rsa_default)(flen, from, to, rsa, padding); -} - -int -rsae_pub_dec(int flen,const u_char *from, u_char *to, RSA *rsa,int padding) -{ - DPRINTF("%s:%d", __func__, __LINE__); - return RSA_meth_get_pub_dec(rsa_default)(flen, from, to, rsa, padding); -} - int rsae_priv_enc(int flen, const u_char *from, u_char *to, RSA *rsa, int padding) { @@ -444,69 +418,10 @@ rsae_priv_dec(int flen, const u_char *from, u_char *to, RSA *rsa, int padding) return rsae_send_imsg(flen, from, to, rsa, padding, IMSG_CA_PRIVDEC); } -int -rsae_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) -{ - DPRINTF("%s:%d", __func__, __LINE__); - return RSA_meth_get_mod_exp(rsa_default)(r0, I, rsa, ctx); -} - -int -rsae_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) -{ - DPRINTF("%s:%d", __func__, __LINE__); - return RSA_meth_get_bn_mod_exp(rsa_default)(r, a, p, m, ctx, m_ctx); -} - -int -rsae_init(RSA *rsa) -{ - DPRINTF("%s:%d", __func__, __LINE__); - if (RSA_meth_get_init(rsa_default) == NULL) - return 1; - return RSA_meth_get_init(rsa_default)(rsa); -} - -int -rsae_finish(RSA *rsa) -{ - DPRINTF("%s:%d", __func__, __LINE__); - if (RSA_meth_get_finish(rsa_default) == NULL) - return 1; - return RSA_meth_get_finish(rsa_default)(rsa); -} - -int -rsae_sign(int type, const u_char *m, u_int m_length, u_char *sigret, - u_int *siglen, const RSA *rsa) -{ - DPRINTF("%s:%d", __func__, __LINE__); - return RSA_meth_get_sign(rsa_default)(type, m, m_length, - sigret, siglen, rsa); -} - -int -rsae_verify(int dtype, const u_char *m, u_int m_length, const u_char *sigbuf, - u_int siglen, const RSA *rsa) -{ - DPRINTF("%s:%d", __func__, __LINE__); - return RSA_meth_get_verify(rsa_default)(dtype, m, m_length, - sigbuf, siglen, rsa); -} - -int -rsae_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb) -{ - DPRINTF("%s:%d", __func__, __LINE__); - return RSA_meth_get_keygen(rsa_default)(rsa, bits, e, cb); -} - void ca_engine_init(struct relayd *x_env) { - ENGINE *e = NULL; - const char *errstr, *name; + const char *errstr; if (env == NULL) env = x_env; @@ -514,68 +429,25 @@ ca_engine_init(struct relayd *x_env) if (rsa_default != NULL) return; - if ((rsae_method = RSA_meth_new("RSA privsep engine", 0)) == NULL) { - errstr = "RSA_meth_new"; + if ((rsa_default = RSA_get_default_method()) == NULL) { + errstr = "RSA_get_default_method"; + goto fail; + } + + if ((rsae_method = RSA_meth_dup(rsa_default)) == NULL) { + errstr = "RSA_meth_dup"; goto fail; } - RSA_meth_set_pub_enc(rsae_method, rsae_pub_enc); - RSA_meth_set_pub_dec(rsae_method, rsae_pub_dec); RSA_meth_set_priv_enc(rsae_method, rsae_priv_enc); RSA_meth_set_priv_dec(rsae_method, rsae_priv_dec); - RSA_meth_set_mod_exp(rsae_method, rsae_mod_exp); - RSA_meth_set_bn_mod_exp(rsae_method, rsae_bn_mod_exp); - RSA_meth_set_init(rsae_method, rsae_init); - RSA_meth_set_finish(rsae_method, rsae_finish); - RSA_meth_set_sign(rsae_method, rsae_sign); - RSA_meth_set_verify(rsae_method, rsae_verify); - RSA_meth_set_keygen(rsae_method, rsae_keygen); - if ((e = ENGINE_get_default_RSA()) == NULL) { - if ((e = ENGINE_new()) == NULL) { - errstr = "ENGINE_new"; - goto fail; - } - if (!ENGINE_set_name(e, RSA_meth_get0_name(rsae_method))) { - errstr = "ENGINE_set_name"; - goto fail; - } - if ((rsa_default = RSA_get_default_method()) == NULL) { - errstr = "RSA_get_default_method"; - goto fail; - } - } else if ((rsa_default = ENGINE_get_RSA(e)) == NULL) { - errstr = "ENGINE_get_RSA"; - goto fail; - } - - if ((name = ENGINE_get_name(e)) == NULL) - name = "unknown RSA engine"; - - log_debug("%s: using %s", __func__, name); - - if (RSA_meth_get_flags(rsa_default) & RSA_FLAG_SIGN_VER) - fatalx("unsupported RSA engine"); - - if (RSA_meth_get_mod_exp(rsa_default) == NULL) - RSA_meth_set_mod_exp(rsae_method, NULL); - if (RSA_meth_get_bn_mod_exp(rsa_default) == NULL) - RSA_meth_set_bn_mod_exp(rsae_method, NULL); - if (RSA_meth_get_keygen(rsa_default) == NULL) - RSA_meth_set_keygen(rsae_method, NULL); RSA_meth_set_flags(rsae_method, RSA_meth_get_flags(rsa_default) | RSA_METHOD_FLAG_NO_CHECK); RSA_meth_set0_app_data(rsae_method, RSA_meth_get0_app_data(rsa_default)); - if (!ENGINE_set_RSA(e, rsae_method)) { - errstr = "ENGINE_set_RSA"; - goto fail; - } - if (!ENGINE_set_default_RSA(e)) { - errstr = "ENGINE_set_default_RSA"; - goto fail; - } + RSA_set_default_method(rsae_method); return; diff --git a/usr.sbin/rpki-client/aspa.c b/usr.sbin/rpki-client/aspa.c index ead8cc9c5..8e5ef060f 100644 --- a/usr.sbin/rpki-client/aspa.c +++ b/usr.sbin/rpki-client/aspa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aspa.c,v 1.21 2023/06/29 14:33:35 tb Exp $ */ +/* $OpenBSD: aspa.c,v 1.22 2023/07/10 12:02:37 job Exp $ */ /* * Copyright (c) 2022 Job Snijders * Copyright (c) 2022 Theo Buehler @@ -43,7 +43,7 @@ struct parse { extern ASN1_OBJECT *aspa_oid; /* - * Types and templates for ASPA eContent draft-ietf-sidrops-aspa-profile-08 + * Types and templates for ASPA eContent draft-ietf-sidrops-aspa-profile-15 */ typedef struct { diff --git a/usr.sbin/rpki-client/print.c b/usr.sbin/rpki-client/print.c index f3904ea7b..cfa5c77a8 100644 --- a/usr.sbin/rpki-client/print.c +++ b/usr.sbin/rpki-client/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.42 2023/06/29 10:22:37 job Exp $ */ +/* $OpenBSD: print.c,v 1.43 2023/07/19 21:49:30 job Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -631,7 +631,7 @@ aspa_print(const X509 *x, const struct aspa *p) if (p->expires) json_do_int("expires", p->expires); json_do_uint("customer_asid", p->custasid); - json_do_array("provider_set"); + json_do_array("providers"); } else { printf("Subject key identifier: %s\n", pretty_key_id(p->ski)); x509_print(x); @@ -645,7 +645,7 @@ aspa_print(const X509 *x, const struct aspa *p) time2str(p->notbefore)); printf("ASPA not after: %s\n", time2str(p->notafter)); printf("Customer ASID: %u\n", p->custasid); - printf("Provider set: "); + printf("Providers: "); } for (i = 0; i < p->providersz; i++) { diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index 1a1bb49a0..28aa13ef9 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.50 2023/06/29 14:33:35 tb Exp $ */ +/* $OpenBSD: repo.c,v 1.51 2023/07/20 05:18:31 claudio Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -873,7 +873,7 @@ rrdp_handle_file(unsigned int id, enum publish_type pt, char *uri, struct filepath *fp; ssize_t s; char *fn = NULL; - int fd = -1, try = 0; + int fd = -1, try = 0, deleted = 0; int flags; rr = rrdp_find(id); @@ -909,8 +909,10 @@ rrdp_handle_file(unsigned int id, enum publish_type pt, char *uri, filepath_add(&rr->deleted, uri, 0); } else { fp = filepath_find(&rr->deleted, uri); - if (fp != NULL) + if (fp != NULL) { filepath_put(&rr->deleted, fp); + deleted = 1; + } /* add new file to rrdp dir */ if ((fn = rrdp_filename(rr, uri, 0)) == NULL) @@ -920,7 +922,7 @@ rrdp_handle_file(unsigned int id, enum publish_type pt, char *uri, goto fail; flags = O_WRONLY|O_CREAT|O_TRUNC; - if (pt == PUB_ADD) + if (pt == PUB_ADD && !deleted) flags |= O_EXCL; fd = open(fn, flags, 0644); if (fd == -1) { diff --git a/usr.sbin/smtpd/ca.c b/usr.sbin/smtpd/ca.c index ccbcb10e3..3476ae2b0 100644 --- a/usr.sbin/smtpd/ca.c +++ b/usr.sbin/smtpd/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.45 2023/06/18 19:08:52 op Exp $ */ +/* $OpenBSD: ca.c,v 1.47 2023/07/11 16:40:22 op Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -31,34 +30,12 @@ static int rsae_send_imsg(int, const unsigned char *, unsigned char *, RSA *, int, unsigned int); -static int rsae_pub_enc(int, const unsigned char *, unsigned char *, - RSA *, int); -static int rsae_pub_dec(int,const unsigned char *, unsigned char *, - RSA *, int); static int rsae_priv_enc(int, const unsigned char *, unsigned char *, RSA *, int); static int rsae_priv_dec(int, const unsigned char *, unsigned char *, RSA *, int); -static int rsae_mod_exp(BIGNUM *, const BIGNUM *, RSA *, BN_CTX *); -static int rsae_bn_mod_exp(BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, BN_CTX *, BN_MONT_CTX *); -static int rsae_init(RSA *); -static int rsae_finish(RSA *); -static int rsae_keygen(RSA *, int, BIGNUM *, BN_GENCB *); -static int ecdsae_keygen(EC_KEY *); -static int ecdsae_compute_key(void *, size_t, const EC_POINT *, EC_KEY *, - void *(*)(const void *, size_t, void *, size_t *)); -static int ecdsae_sign(int, const unsigned char *, int, unsigned char *, - unsigned int *, const BIGNUM *, const BIGNUM *, EC_KEY *); - static ECDSA_SIG *ecdsae_do_sign(const unsigned char *, int, const BIGNUM *, const BIGNUM *, EC_KEY *); -static int ecdsae_sign_setup(EC_KEY *, BN_CTX *, BIGNUM **, BIGNUM **); -static int ecdsae_verify(int, const unsigned char *, int, const unsigned char *, - int, EC_KEY *); -static int ecdsae_do_verify(const unsigned char *, int, const ECDSA_SIG *, - EC_KEY *); - static struct dict pkeys; static uint64_t reqid = 0; @@ -391,22 +368,6 @@ rsae_send_imsg(int flen, const unsigned char *from, unsigned char *to, return (ret); } -static int -rsae_pub_enc(int flen,const unsigned char *from, unsigned char *to, RSA *rsa, - int padding) -{ - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - return (RSA_meth_get_pub_enc(rsa_default)(flen, from, to, rsa, padding)); -} - -static int -rsae_pub_dec(int flen,const unsigned char *from, unsigned char *to, RSA *rsa, - int padding) -{ - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - return (RSA_meth_get_pub_dec(rsa_default)(flen, from, to, rsa, padding)); -} - static int rsae_priv_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) @@ -430,47 +391,6 @@ rsae_priv_dec(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, return (RSA_meth_get_priv_dec(rsa_default)(flen, from, to, rsa, padding)); } -static int -rsae_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) -{ - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - return (RSA_meth_get_mod_exp(rsa_default)(r0, I, rsa, ctx)); -} - -static int -rsae_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) -{ - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - return (RSA_meth_get_bn_mod_exp(rsa_default)(r, a, p, m, ctx, m_ctx)); -} - -static int -rsae_init(RSA *rsa) -{ - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - if (RSA_meth_get_init(rsa_default) == NULL) - return (1); - return (RSA_meth_get_init(rsa_default)(rsa)); -} - -static int -rsae_finish(RSA *rsa) -{ - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - if (RSA_meth_get_finish(rsa_default) == NULL) - return (1); - return (RSA_meth_get_finish(rsa_default)(rsa)); -} - -static int -rsae_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb) -{ - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - return (RSA_meth_get_keygen(rsa_default)(rsa, bits, e, cb)); -} - - /* * ECDSA privsep engine (called from unprivileged processes) */ @@ -553,40 +473,6 @@ ecdsae_send_enc_imsg(const unsigned char *dgst, int dgst_len, return (sig); } -static int -ecdsae_keygen(EC_KEY *eckey) -{ - int (*keygen)(EC_KEY *); - - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - EC_KEY_METHOD_get_keygen(ecdsa_default, &keygen); - return (keygen(eckey)); -} - -static int -ecdsae_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, - EC_KEY *ecdh, void *(*kdf)(const void *, size_t, void *, size_t *)) -{ - int (*ckey)(void *, size_t, const EC_POINT *, EC_KEY *, - void *(*)(const void *, size_t, void *, size_t *)); - - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - EC_KEY_METHOD_get_compute_key(ecdsa_default, &ckey); - return (ckey(out, outlen, pub_key, ecdh, kdf)); -} - -static int -ecdsae_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, - unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey) -{ - int (*sign)(int, const unsigned char *, int, unsigned char *, - unsigned int *, const BIGNUM *, const BIGNUM *, EC_KEY *); - - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - EC_KEY_METHOD_get_sign(ecdsa_default, &sign, NULL, NULL); - return (sign(type, dgst, dlen, sig, siglen, kinv, r, eckey)); -} - static ECDSA_SIG * ecdsae_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, const BIGNUM *rp, EC_KEY *eckey) @@ -601,104 +487,30 @@ ecdsae_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, return (psign_sig(dgst, dgst_len, inv, rp, eckey)); } -static int -ecdsae_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **r) -{ - int (*psign_setup)(EC_KEY *, BN_CTX *, BIGNUM **, BIGNUM **); - - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - EC_KEY_METHOD_get_sign(ecdsa_default, NULL, &psign_setup, NULL); - return (psign_setup(eckey, ctx, kinv, r)); -} - -static int -ecdsae_verify(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int sig_len, EC_KEY *eckey) -{ - int (*verify)(int, const unsigned char *, int, const unsigned char *, - int, EC_KEY *); - - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - EC_KEY_METHOD_get_verify(ecdsa_default, &verify, NULL); - return (verify(type, dgst, dgst_len, sigbuf, sig_len, eckey)); -} - -static int -ecdsae_do_verify(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey) -{ - int (*pverify_sig)(const unsigned char *, int, const ECDSA_SIG *, - EC_KEY *); - - log_debug("debug: %s: %s", proc_name(smtpd_process), __func__); - EC_KEY_METHOD_get_verify(ecdsa_default, NULL, &pverify_sig); - return (pverify_sig(dgst, dgst_len, sig, eckey)); -} - - static void rsa_engine_init(void) { - ENGINE *e; - const char *errstr, *name; + const char *errstr; - if ((rsae_method = RSA_meth_new("RSA privsep engine", 0)) == NULL) { - errstr = "RSA_meth_new"; + if ((rsa_default = RSA_get_default_method()) == NULL) { + errstr = "RSA_get_default_method"; + goto fail; + } + + if ((rsae_method = RSA_meth_dup(rsa_default)) == NULL) { + errstr = "RSA_meth_dup"; goto fail; } - RSA_meth_set_pub_enc(rsae_method, rsae_pub_enc); - RSA_meth_set_pub_dec(rsae_method, rsae_pub_dec); RSA_meth_set_priv_enc(rsae_method, rsae_priv_enc); RSA_meth_set_priv_dec(rsae_method, rsae_priv_dec); - RSA_meth_set_mod_exp(rsae_method, rsae_mod_exp); - RSA_meth_set_bn_mod_exp(rsae_method, rsae_bn_mod_exp); - RSA_meth_set_init(rsae_method, rsae_init); - RSA_meth_set_finish(rsae_method, rsae_finish); - RSA_meth_set_keygen(rsae_method, rsae_keygen); - if ((e = ENGINE_get_default_RSA()) == NULL) { - if ((e = ENGINE_new()) == NULL) { - errstr = "ENGINE_new"; - goto fail; - } - if (!ENGINE_set_name(e, RSA_meth_get0_name(rsae_method))) { - errstr = "ENGINE_set_name"; - goto fail; - } - if ((rsa_default = RSA_get_default_method()) == NULL) { - errstr = "RSA_get_default_method"; - goto fail; - } - } else if ((rsa_default = ENGINE_get_RSA(e)) == NULL) { - errstr = "ENGINE_get_RSA"; - goto fail; - } - - if ((name = ENGINE_get_name(e)) == NULL) - name = "unknown RSA engine"; - - log_debug("debug: %s: using %s", __func__, name); - - if (RSA_meth_get_mod_exp(rsa_default) == NULL) - RSA_meth_set_mod_exp(rsae_method, NULL); - if (RSA_meth_get_bn_mod_exp(rsa_default) == NULL) - RSA_meth_set_bn_mod_exp(rsae_method, NULL); - if (RSA_meth_get_keygen(rsa_default) == NULL) - RSA_meth_set_keygen(rsae_method, NULL); RSA_meth_set_flags(rsae_method, RSA_meth_get_flags(rsa_default) | RSA_METHOD_FLAG_NO_CHECK); RSA_meth_set0_app_data(rsae_method, RSA_meth_get0_app_data(rsa_default)); - if (!ENGINE_set_RSA(e, rsae_method)) { - errstr = "ENGINE_set_RSA"; - goto fail; - } - if (!ENGINE_set_default_RSA(e)) { - errstr = "ENGINE_set_default_RSA"; - goto fail; - } + RSA_set_default_method(rsae_method); return; @@ -710,52 +522,26 @@ rsa_engine_init(void) static void ecdsa_engine_init(void) { - ENGINE *e; - const char *errstr, *name; + int (*sign)(int, const unsigned char *, int, unsigned char *, + unsigned int *, const BIGNUM *, const BIGNUM *, EC_KEY *); + int (*sign_setup)(EC_KEY *, BN_CTX *, BIGNUM **, BIGNUM **); + const char *errstr; - if ((ecdsae_method = EC_KEY_METHOD_new(NULL)) == NULL) { + if ((ecdsa_default = EC_KEY_get_default_method()) == NULL) { + errstr = "EC_KEY_get_default_method"; + goto fail; + } + + if ((ecdsae_method = EC_KEY_METHOD_new(ecdsa_default)) == NULL) { errstr = "EC_KEY_METHOD_new"; goto fail; } - EC_KEY_METHOD_set_keygen(ecdsae_method, ecdsae_keygen); - EC_KEY_METHOD_set_compute_key(ecdsae_method, ecdsae_compute_key); - EC_KEY_METHOD_set_sign(ecdsae_method, ecdsae_sign, ecdsae_sign_setup, + EC_KEY_METHOD_get_sign(ecdsa_default, &sign, &sign_setup, NULL); + EC_KEY_METHOD_set_sign(ecdsae_method, sign, sign_setup, ecdsae_do_sign); - EC_KEY_METHOD_set_verify(ecdsae_method, ecdsae_verify, - ecdsae_do_verify); - if ((e = ENGINE_get_default_EC()) == NULL) { - if ((e = ENGINE_new()) == NULL) { - errstr = "ENGINE_new"; - goto fail; - } - if (!ENGINE_set_name(e, "ECDSA privsep engine")) { - errstr = "ENGINE_set_name"; - goto fail; - } - if ((ecdsa_default = EC_KEY_get_default_method()) == NULL) { - errstr = "EC_KEY_get_default_method"; - goto fail; - } - } else if ((ecdsa_default = ENGINE_get_EC(e)) == NULL) { - errstr = "ENGINE_get_EC"; - goto fail; - } - - if ((name = ENGINE_get_name(e)) == NULL) - name = "unknown ECDSA engine"; - - log_debug("debug: %s: using %s", __func__, name); - - if (!ENGINE_set_EC(e, ecdsae_method)) { - errstr = "ENGINE_set_EC"; - goto fail; - } - if (!ENGINE_set_default_EC(e)) { - errstr = "ENGINE_set_default_EC"; - goto fail; - } + EC_KEY_set_default_method(ecdsae_method); return; diff --git a/usr.sbin/vmd/config.c b/usr.sbin/vmd/config.c index b538d40be..3bb246a00 100644 --- a/usr.sbin/vmd/config.c +++ b/usr.sbin/vmd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.71 2023/04/28 19:46:42 dv Exp $ */ +/* $OpenBSD: config.c,v 1.72 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -47,9 +47,7 @@ static int config_init_localprefix(struct vmd_config *); static int config_init_localprefix(struct vmd_config *cfg) { - struct sockaddr_in6 *sin6; - - if (host(VMD_DHCP_PREFIX, &cfg->cfg_localprefix) == -1) + if (parse_prefix4(VMD_DHCP_PREFIX, &cfg->cfg_localprefix, NULL) == -1) return (-1); /* IPv6 is disabled by default */ @@ -58,11 +56,11 @@ config_init_localprefix(struct vmd_config *cfg) /* Generate random IPv6 prefix only once */ if (cfg->cfg_flags & VMD_CFG_AUTOINET6) return (0); - if (host(VMD_ULA_PREFIX, &cfg->cfg_localprefix6) == -1) + if (parse_prefix6(VMD_ULA_PREFIX, &cfg->cfg_localprefix, NULL) == -1) return (-1); + /* Randomize the 56 bits "Global ID" and "Subnet ID" */ - sin6 = ss2sin6(&cfg->cfg_localprefix6.ss); - arc4random_buf(&sin6->sin6_addr.s6_addr[1], 7); + arc4random_buf(&cfg->cfg_localprefix.lp_in6.s6_addr[1], 7); cfg->cfg_flags |= VMD_CFG_AUTOINET6; return (0); diff --git a/usr.sbin/vmd/dhcp.c b/usr.sbin/vmd/dhcp.c index 3b8744ffe..67ab546b4 100644 --- a/usr.sbin/vmd/dhcp.c +++ b/usr.sbin/vmd/dhcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp.c,v 1.12 2023/04/27 22:47:27 dv Exp $ */ +/* $OpenBSD: dhcp.c,v 1.13 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2017 Reyk Floeter @@ -40,7 +40,6 @@ (1500 - sizeof(struct ip) - sizeof(struct udphdr) - OPTIONS_OFFSET) static const uint8_t broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -extern struct vmd *env; ssize_t dhcp_request(struct virtio_dev *dev, char *buf, size_t buflen, char **obuf) @@ -146,8 +145,7 @@ dhcp_request(struct virtio_dev *dev, char *buf, size_t buflen, char **obuf) hostname = vm->vm_params.vmc_params.vcp_name; } - if ((client_addr.s_addr = - vm_priv_addr(&env->vmd_cfg, + if ((client_addr.s_addr = vm_priv_addr(&vionet->local_prefix, dev->vm_vmid, vionet->idx, 1)) == 0) return (-1); memcpy(&resp.yiaddr, &client_addr, @@ -156,8 +154,8 @@ dhcp_request(struct virtio_dev *dev, char *buf, size_t buflen, char **obuf) sizeof(client_addr)); ss2sin(&pc.pc_dst)->sin_port = htons(CLIENT_PORT); - if ((server_addr.s_addr = vm_priv_addr(&env->vmd_cfg, dev->vm_vmid, - vionet->idx, 0)) == 0) + if ((server_addr.s_addr = vm_priv_addr(&vionet->local_prefix, + dev->vm_vmid, vionet->idx, 0)) == 0) return (-1); memcpy(&resp.siaddr, &server_addr, sizeof(server_addr)); memcpy(&ss2sin(&pc.pc_src)->sin_addr, &server_addr, diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y index 09468e3fe..2ee988972 100644 --- a/usr.sbin/vmd/parse.y +++ b/usr.sbin/vmd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.67 2023/04/28 21:22:20 dv Exp $ */ +/* $OpenBSD: parse.y,v 1.68 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2007-2016 Reyk Floeter @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -189,32 +190,27 @@ main : LOCAL INET6 { env->vmd_cfg.cfg_flags |= VMD_CFG_INET6; } | LOCAL INET6 PREFIX STRING { - struct address h; + const char *err; - if (host($4, &h) == -1 || - h.ss.ss_family != AF_INET6 || - h.prefixlen > 64 || h.prefixlen < 0) { - yyerror("invalid local inet6 prefix: %s", $4); - free($4); + if (parse_prefix6($4, &env->vmd_cfg.cfg_localprefix, + &err)) { + yyerror("invalid local inet6 prefix: %s", err); YYERROR; + } else { + env->vmd_cfg.cfg_flags |= VMD_CFG_INET6; + env->vmd_cfg.cfg_flags &= ~VMD_CFG_AUTOINET6; } - - env->vmd_cfg.cfg_flags |= VMD_CFG_INET6; - env->vmd_cfg.cfg_flags &= ~VMD_CFG_AUTOINET6; - memcpy(&env->vmd_cfg.cfg_localprefix6, &h, sizeof(h)); + free($4); } | LOCAL PREFIX STRING { - struct address h; + const char *err; - if (host($3, &h) == -1 || - h.ss.ss_family != AF_INET || - h.prefixlen > 32 || h.prefixlen < 0) { - yyerror("invalid local prefix: %s", $3); - free($3); + if (parse_prefix4($3, &env->vmd_cfg.cfg_localprefix, + &err)) { + yyerror("invalid local prefix: %s", err); YYERROR; } - - memcpy(&env->vmd_cfg.cfg_localprefix, &h, sizeof(h)); + free($3); } | SOCKET OWNER owner_id { env->vmd_ps.ps_csock.cs_uid = $3.uid; @@ -1404,42 +1400,133 @@ parse_format(const char *word) return (0); } +/* + * Parse an ipv4 address and prefix for local interfaces and validate + * constraints for vmd networking. + */ int -host(const char *str, struct address *h) +parse_prefix4(const char *str, struct local_prefix *out, const char **errstr) { - struct addrinfo hints, *res; - int prefixlen; - char *s, *p; - const char *errstr; + struct addrinfo hints, *res = NULL; + struct sockaddr_storage ss; + struct in_addr addr; + int mask = 16; + char *p, *ps; - if ((s = strdup(str)) == NULL) { - log_warn("%s", __func__); - goto fail; - } + if ((ps = strdup(str)) == NULL) + fatal("%s: strdup", __func__); - if ((p = strrchr(s, '/')) != NULL) { - *p++ = '\0'; - prefixlen = strtonum(p, 0, 128, &errstr); - if (errstr) { - log_warnx("prefixlen is %s: %s", errstr, p); - goto fail; + if ((p = strrchr(ps, '/')) != NULL) { + mask = strtonum(p + 1, 1, 16, errstr); + if (errstr != NULL && *errstr) { + free(ps); + return (1); } - } else - prefixlen = 128; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_flags = AI_NUMERICHOST; - if (getaddrinfo(s, NULL, &hints, &res) == 0) { - memset(h, 0, sizeof(*h)); - memcpy(&h->ss, res->ai_addr, res->ai_addrlen); - h->prefixlen = prefixlen; - freeaddrinfo(res); - free(s); - return (0); + p[0] = '\0'; } - fail: - free(s); - return (-1); + /* Attempt to construct an address from the user input. */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = AI_NUMERICHOST; + + if (getaddrinfo(ps, NULL, &hints, &res) == 0) { + memset(&ss, 0, sizeof(ss)); + memcpy(&ss, res->ai_addr, res->ai_addrlen); + addr.s_addr = ss2sin(&ss)->sin_addr.s_addr; + freeaddrinfo(res); + } else { /* try 10/8 parsing */ + memset(&addr, 0, sizeof(addr)); + if (inet_net_pton(AF_INET, ps, &addr, sizeof(addr)) == -1) { + if (errstr) + *errstr = "invalid format"; + free(ps); + return (1); + } + } + free(ps); + + /* + * Validate the prefix by comparing it with the mask. Since we + * constrain the mask length to 16 above, this also validates + * we reserve the last 16 bits for use by vmd to assign vm id + * and interface id. + */ + if ((addr.s_addr & prefixlen2mask(mask)) != addr.s_addr) { + if (errstr) + *errstr = "bad mask"; + return (1); + } + + /* Copy out the local prefix. */ + out->lp_in.s_addr = addr.s_addr; + out->lp_mask.s_addr = prefixlen2mask(mask); + return (0); +} + +/* + * Parse an ipv6 address and prefix for local interfaces and validate + * constraints for vmd networking. + */ +int +parse_prefix6(const char *str, struct local_prefix *out, const char **errstr) +{ + struct addrinfo hints, *res = NULL; + struct sockaddr_storage ss; + struct in6_addr addr6, mask6; + size_t i; + int mask = 64, err; + char *p, *ps; + + if ((ps = strdup(str)) == NULL) + fatal("%s: strdup", __func__); + + if ((p = strrchr(ps, '/')) != NULL) { + mask = strtonum(p + 1, 0, 64, errstr); + if (errstr != NULL && *errstr) { + free(ps); + return (1); + } + p[0] = '\0'; + } + + /* Attempt to construct an address from the user input. */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = AI_NUMERICHOST; + + if ((err = getaddrinfo(ps, NULL, &hints, &res)) != 0) { + if (errstr) + *errstr = gai_strerror(err); + free(ps); + return (1); + } + free(ps); + + memset(&ss, 0, sizeof(ss)); + memcpy(&ss, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); + + memcpy(&addr6, (void*)&ss2sin6(&ss)->sin6_addr, sizeof(addr6)); + prefixlen2mask6(mask, &mask6); + + /* + * Validate the prefix by comparing it with the mask. Since we + * constrain the mask length to 64 above, this also validates + * that we're reserving bits for the encoding of the ipv4 + * address, the vm id, and interface id. */ + for (i = 0; i < 16; i++) { + if ((addr6.s6_addr[i] & mask6.s6_addr[i]) != addr6.s6_addr[i]) { + if (errstr) + *errstr = "bad mask"; + return (1); + } + } + + /* Copy out the local prefix. */ + memcpy(&out->lp_in6, &addr6, sizeof(out->lp_in6)); + memcpy(&out->lp_mask6, &mask6, sizeof(out->lp_mask6)); + return (0); } diff --git a/usr.sbin/vmd/priv.c b/usr.sbin/vmd/priv.c index a7a7a2bc2..bfb15085c 100644 --- a/usr.sbin/vmd/priv.c +++ b/usr.sbin/vmd/priv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: priv.c,v 1.22 2023/01/28 14:40:53 dv Exp $ */ +/* $OpenBSD: priv.c,v 1.23 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2016 Reyk Floeter @@ -466,7 +466,7 @@ vm_priv_ifconfig(struct privsep *ps, struct vmd_vm *vm) sin4->sin_family = AF_INET; sin4->sin_len = sizeof(*sin4); if ((sin4->sin_addr.s_addr = - vm_priv_addr(&env->vmd_cfg, + vm_priv_addr(&env->vmd_cfg.cfg_localprefix, vm->vm_vmid, i, 0)) == 0) return (-1); @@ -493,7 +493,7 @@ vm_priv_ifconfig(struct privsep *ps, struct vmd_vm *vm) sin6 = ss2sin6(&vfr.vfr_addr); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); - if (vm_priv_addr6(&env->vmd_cfg, + if (vm_priv_addr6(&env->vmd_cfg.cfg_localprefix, vm->vm_vmid, i, 0, &sin6->sin6_addr) == -1) return (-1); @@ -565,43 +565,33 @@ vm_priv_brconfig(struct privsep *ps, struct vmd_switch *vsw) } uint32_t -vm_priv_addr(struct vmd_config *cfg, uint32_t vmid, int idx, int isvm) +vm_priv_addr(struct local_prefix *p, uint32_t vmid, int idx, int isvm) { - struct address *h = &cfg->cfg_localprefix; - in_addr_t prefix, mask, addr; + in_addr_t addr; - /* - * 1. Set the address prefix and mask, 100.64.0.0/10 by default. - */ - if (h->ss.ss_family != AF_INET || - h->prefixlen < 0 || h->prefixlen > 32) - fatal("local prefix"); - prefix = ss2sin(&h->ss)->sin_addr.s_addr; - mask = prefixlen2mask(h->prefixlen); - - /* 2. Encode the VM ID as a per-VM subnet range N, 100.64.N.0/24. */ + /* Encode the VM ID as a per-VM subnet range N, 100.64.N.0/24. */ addr = vmid << 8; /* - * 3. Assign a /31 subnet M per VM interface, 100.64.N.M/31. + * Assign a /31 subnet M per VM interface, 100.64.N.M/31. * Each subnet contains exactly two IP addresses; skip the * first subnet to avoid a gateway address ending with .0. */ addr |= (idx + 1) * 2; - /* 4. Use the first address for the gateway, the second for the VM. */ + /* Use the first address for the gateway, the second for the VM. */ if (isvm) addr++; - /* 5. Convert to network byte order and add the prefix. */ - addr = htonl(addr) | prefix; + /* Convert to network byte order and add the prefix. */ + addr = htonl(addr) | p->lp_in.s_addr; /* * Validate the results: * - the address should not exceed the prefix (eg. VM ID to high). * - up to 126 interfaces can be encoded per VM. */ - if (prefix != (addr & mask) || idx >= 0x7f) { + if (p->lp_in.s_addr != (addr & p->lp_mask.s_addr) || idx >= 0x7f) { log_warnx("%s: dhcp address range exceeded," " vm id %u interface %d", __func__, vmid, idx); return (0); @@ -611,27 +601,22 @@ vm_priv_addr(struct vmd_config *cfg, uint32_t vmid, int idx, int isvm) } int -vm_priv_addr6(struct vmd_config *cfg, uint32_t vmid, - int idx, int isvm, struct in6_addr *in6_addr) +vm_priv_addr6(struct local_prefix *p, uint32_t vmid, int idx, int isvm, + struct in6_addr *out) { - struct address *h = &cfg->cfg_localprefix6; - struct in6_addr addr, mask; - uint32_t addr4; + struct in6_addr addr; + in_addr_t addr4; - /* 1. Set the address prefix and mask, fd00::/8 by default. */ - if (h->ss.ss_family != AF_INET6 || - h->prefixlen < 0 || h->prefixlen > 128) - fatal("local prefix6"); - addr = ss2sin6(&h->ss)->sin6_addr; - prefixlen2mask6(h->prefixlen, &mask); + /* Start with the IPv6 prefix. */ + memcpy(&addr, &p->lp_in6, sizeof(addr)); - /* 2. Encode the VM IPv4 address as subnet, fd00::NN:NN:0:0/96. */ - if ((addr4 = vm_priv_addr(cfg, vmid, idx, 1)) == 0) + /* Encode the VM IPv4 address as subnet, fd00::NN:NN:0:0/96. */ + if ((addr4 = vm_priv_addr(p, vmid, idx, 1)) == 0) return (0); memcpy(&addr.s6_addr[8], &addr4, sizeof(addr4)); /* - * 3. Set the last octet to 1 (host) or 2 (VM). + * Set the last octet to 1 (host) or 2 (VM). * The latter is currently not used inside vmd as we don't * answer rtsol requests ourselves. */ @@ -640,7 +625,7 @@ vm_priv_addr6(struct vmd_config *cfg, uint32_t vmid, else addr.s6_addr[15] = 2; - memcpy(in6_addr, &addr, sizeof(*in6_addr)); + memcpy(out, &addr, sizeof(*out)); return (0); } diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c index d29b9e7b8..a58e35115 100644 --- a/usr.sbin/vmd/virtio.c +++ b/usr.sbin/vmd/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.103 2023/05/13 23:15:28 dv Exp $ */ +/* $OpenBSD: virtio.c,v 1.105 2023/07/15 18:32:21 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -591,7 +591,9 @@ virtio_init(struct vmd_vm *vm, int child_cdrom, vmc->vmc_ifflags[i] & VMIFF_LOCAL ? 1 : 0; if (i == 0 && vmc->vmc_bootdevice & VMBOOTDEV_NET) dev->vionet.pxeboot = 1; - + memcpy(&dev->vionet.local_prefix, + &env->vmd_cfg.cfg_localprefix, + sizeof(dev->vionet.local_prefix)); log_debug("%s: vm \"%s\" vio%u lladdr %s%s%s%s", __func__, vcp->vcp_name, i, ether_ntoa((void *)dev->vionet.mac), @@ -1300,8 +1302,7 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) char *nargv[10], num[32], vmm_fd[32], t[2]; pid_t dev_pid; int data_fds[VM_MAX_BASE_PER_DISK], sync_fds[2], async_fds[2], ret = 0; - size_t i, j, data_fds_sz, sz = 0; - struct virtio_dev *d = NULL; + size_t i, data_fds_sz, sz = 0; struct viodev_msg msg; struct imsg imsg; struct imsgev *iev = &dev->sync_iev; @@ -1347,17 +1348,6 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) goto err; } - /* Keep data file descriptors open after exec. */ - for (i = 0; i < data_fds_sz; i++) { - log_debug("%s: marking fd %d !close-on-exec", __func__, - data_fds[i]); - if (fcntl(data_fds[i], F_SETFD, 0)) { - ret = errno; - log_warn("%s: fcntl", __func__); - goto err; - } - } - /* Fork... */ dev_pid = fork(); if (dev_pid == -1) { @@ -1457,26 +1447,14 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) close_fd(async_fds[0]); close_fd(sync_fds[0]); - /* - * Close any other device fd's we know aren't - * ours. This releases any exclusive locks held on - * things like disk images. - */ - SLIST_FOREACH(d, &virtio_devs, dev_next) { - if (d == dev) - continue; - - switch (d->dev_type) { - case VMD_DEVTYPE_DISK: - for (j = 0; j < d->vioblk.ndisk_fd; j++) - close_fd(d->vioblk.disk_fd[j]); - break; - case VMD_DEVTYPE_NET: - close_fd(d->vionet.data_fd); - break; - default: - fatalx("%s: invalid device type '%c'", - __func__, d->dev_type); + /* Keep data file descriptors open after exec. */ + for (i = 0; i < data_fds_sz; i++) { + log_debug("%s: marking fd %d !close-on-exec", __func__, + data_fds[i]); + if (fcntl(data_fds[i], F_SETFD, 0)) { + ret = errno; + log_warn("%s: fcntl", __func__); + goto err; } } diff --git a/usr.sbin/vmd/virtio.h b/usr.sbin/vmd/virtio.h index 285c11630..24fd0097a 100644 --- a/usr.sbin/vmd/virtio.h +++ b/usr.sbin/vmd/virtio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.h,v 1.45 2023/04/27 22:47:27 dv Exp $ */ +/* $OpenBSD: virtio.h,v 1.46 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -257,6 +257,7 @@ struct vionet_dev { int lockedmac; int local; int pxeboot; + struct local_prefix local_prefix; unsigned int idx; }; diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c index 8ec69d605..5f598bcc1 100644 --- a/usr.sbin/vmd/vm.c +++ b/usr.sbin/vmd/vm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm.c,v 1.89 2023/05/13 23:15:28 dv Exp $ */ +/* $OpenBSD: vm.c,v 1.90 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -259,6 +259,14 @@ vm_main(int fd, int vmm_fd) setproctitle("%s", vcp->vcp_name); log_procinit(vcp->vcp_name); + /* Receive the local prefix settings. */ + sz = atomicio(read, fd, &env->vmd_cfg.cfg_localprefix, + sizeof(env->vmd_cfg.cfg_localprefix)); + if (sz != sizeof(env->vmd_cfg.cfg_localprefix)) { + log_warnx("failed to receive local prefix"); + _exit(EIO); + } + /* * We need, at minimum, a vm_kernel fd to boot a vm. This is either a * kernel or a BIOS image. diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h index 9c25b0c92..744b8d195 100644 --- a/usr.sbin/vmd/vmd.h +++ b/usr.sbin/vmd/vmd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.h,v 1.122 2023/05/13 23:15:28 dv Exp $ */ +/* $OpenBSD: vmd.h,v 1.123 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -341,12 +341,12 @@ struct name2id { }; TAILQ_HEAD(name2idlist, name2id); -struct address { - struct sockaddr_storage ss; - int prefixlen; - TAILQ_ENTRY(address) entry; +struct local_prefix { + struct in_addr lp_in; + struct in_addr lp_mask; + struct in6_addr lp_in6; + struct in6_addr lp_mask6; }; -TAILQ_HEAD(addresslist, address); #define SUN_PATH_LEN (sizeof(((struct sockaddr_un *)NULL)->sun_path)) struct vmd_agentx { @@ -367,8 +367,7 @@ struct vmd_config { struct timeval delay; int parallelism; - struct address cfg_localprefix; - struct address cfg_localprefix6; + struct local_prefix cfg_localprefix; struct vmd_agentx cfg_agentx; }; @@ -473,9 +472,9 @@ int priv_findname(const char *, const char **); int priv_validgroup(const char *); int vm_priv_ifconfig(struct privsep *, struct vmd_vm *); int vm_priv_brconfig(struct privsep *, struct vmd_switch *); -uint32_t vm_priv_addr(struct vmd_config *, uint32_t, int, int); -int vm_priv_addr6(struct vmd_config *, uint32_t, int, int, - struct in6_addr *); +uint32_t vm_priv_addr(struct local_prefix *, uint32_t, int, int); +int vm_priv_addr6(struct local_prefix *, uint32_t, int, int, + struct in6_addr *); /* vmm.c */ void vmm(struct privsep *, struct privsep_proc *); @@ -518,7 +517,8 @@ void vm_agentx_shutdown(void); /* parse.y */ int parse_config(const char *); int cmdline_symset(char *); -int host(const char *, struct address *); +int parse_prefix4(const char *, struct local_prefix *, const char **); +int parse_prefix6(const char *, struct local_prefix *, const char **); /* virtio.c */ int virtio_get_base(int, char *, size_t, int, const char *); diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index 7f307f99c..541222e02 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.112 2023/05/13 23:15:28 dv Exp $ */ +/* $OpenBSD: vmm.c,v 1.113 2023/07/13 18:31:59 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -701,6 +701,16 @@ vmm_start_vm(struct imsg *imsg, uint32_t *id, pid_t *pid) if (ret == EIO) goto err; + /* Send the current local prefix configuration. */ + sz = atomicio(vwrite, fds[0], &env->vmd_cfg.cfg_localprefix, + sizeof(env->vmd_cfg.cfg_localprefix)); + if (sz != sizeof(env->vmd_cfg.cfg_localprefix)) { + log_warnx("%s: failed to send local prefix for vm '%s'", + __func__, vcp->vcp_name); + ret = EIO; + goto err; + } + /* Read back the kernel-generated vm id from the child */ sz = atomicio(read, fds[0], &vcp->vcp_id, sizeof(vcp->vcp_id)); if (sz != sizeof(vcp->vcp_id)) { diff --git a/usr.sbin/ypldap/entries.c b/usr.sbin/ypldap/entries.c index 3d259e6e4..1387d1153 100644 --- a/usr.sbin/ypldap/entries.c +++ b/usr.sbin/ypldap/entries.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entries.c,v 1.5 2022/02/05 22:59:58 naddy Exp $ */ +/* $OpenBSD: entries.c,v 1.6 2023/07/18 13:06:33 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard * @@ -34,6 +34,7 @@ #include #include "ypldap.h" +#include "log.h" void flatten_entries(struct env *env) diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index eb2b80593..cee23af20 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.48 2023/05/22 05:59:05 jmatthew Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.49 2023/07/18 13:06:33 claudio Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver @@ -115,6 +115,9 @@ client_sig_handler(int sig, short event, void *p) case SIGTERM: client_shutdown(); break; + case SIGHUP: + /* ingore */ + break; default: fatalx("unexpected signal"); } @@ -326,6 +329,7 @@ ldapclient(int pipe_main2client[2]) struct passwd *pw; struct event ev_sigint; struct event ev_sigterm; + struct event ev_sighup; struct env env; switch (pid = fork()) { @@ -377,8 +381,10 @@ ldapclient(int pipe_main2client[2]) signal(SIGPIPE, SIG_IGN); signal_set(&ev_sigint, SIGINT, client_sig_handler, NULL); signal_set(&ev_sigterm, SIGTERM, client_sig_handler, NULL); + signal_set(&ev_sighup, SIGHUP, client_sig_handler, NULL); signal_add(&ev_sigint, NULL); signal_add(&ev_sigterm, NULL); + signal_add(&ev_sighup, NULL); close(pipe_main2client[0]); if ((env.sc_iev = calloc(1, sizeof(*env.sc_iev))) == NULL) diff --git a/usr.sbin/ypldap/parse.y b/usr.sbin/ypldap/parse.y index fbe1b8bb7..9573e83b2 100644 --- a/usr.sbin/ypldap/parse.y +++ b/usr.sbin/ypldap/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.36 2022/10/13 04:55:33 jmatthew Exp $ */ +/* $OpenBSD: parse.y,v 1.37 2023/07/18 13:06:33 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -51,6 +51,7 @@ #include #include "ypldap.h" +#include "log.h" TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); static struct file { diff --git a/usr.sbin/ypldap/yp.c b/usr.sbin/ypldap/yp.c index c19307677..25aaddf15 100644 --- a/usr.sbin/ypldap/yp.c +++ b/usr.sbin/ypldap/yp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp.c,v 1.21 2022/08/19 03:50:32 jmatthew Exp $ */ +/* $OpenBSD: yp.c,v 1.22 2023/07/18 13:06:33 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard * @@ -44,6 +44,7 @@ #include #include "ypldap.h" +#include "log.h" #define BINDINGDIR "/var/yp/binding" diff --git a/usr.sbin/ypldap/ypldap.h b/usr.sbin/ypldap/ypldap.h index 1f9a16d81..8baa0f12b 100644 --- a/usr.sbin/ypldap/ypldap.h +++ b/usr.sbin/ypldap/ypldap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap.h,v 1.23 2022/10/13 04:55:33 jmatthew Exp $ */ +/* $OpenBSD: ypldap.h,v 1.24 2023/07/18 13:06:33 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -193,17 +193,6 @@ struct env { int update_trashed; }; -/* log.c */ -void log_init(int); -void log_warn(const char *, ...); -void log_warnx(const char *, ...); -void log_info(const char *, ...); -void log_debug(const char *, ...); -void logit(int, const char *, ...); -void vlog(int, const char *, va_list); -__dead void fatal(const char *); -__dead void fatalx(const char *); - /* parse.y */ int parse_config(struct env *, const char *, int); int cmdline_symset(char *); diff --git a/usr.sbin/ypldap/ypldap_dns.c b/usr.sbin/ypldap/ypldap_dns.c index 59835a80e..6645e1100 100644 --- a/usr.sbin/ypldap/ypldap_dns.c +++ b/usr.sbin/ypldap/ypldap_dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap_dns.c,v 1.15 2022/08/23 02:57:27 jmatthew Exp $ */ +/* $OpenBSD: ypldap_dns.c,v 1.16 2023/07/18 13:06:33 claudio Exp $ */ /* * Copyright (c) 2003-2008 Henning Brauer @@ -38,6 +38,7 @@ #include #include "ypldap.h" +#include "log.h" volatile sig_atomic_t quit_dns = 0; struct imsgev *iev_dns; @@ -55,6 +56,9 @@ dns_sig_handler(int sig, short event, void *p) case SIGTERM: dns_shutdown(); break; + case SIGHUP: + /* ignore */ + break; default: fatalx("unexpected signal"); } @@ -70,7 +74,7 @@ dns_shutdown(void) pid_t ypldap_dns(int pipe_ntp[2], struct passwd *pw) { - pid_t pid; + pid_t pid; struct event ev_sigint; struct event ev_sigterm; struct event ev_sighup;