Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux-watchdog-4.16-fixes-2' of git://www.linux-watchdog.org/linux-watchdog

Pull watchdog fixes from Wim Van Sebroeck:

- f71808e_wdt: Fix magic close handling

- sbsa: 32-bit read fix for WCV

- hpwdt: Remove legacy NMI sourcing

* tag 'linux-watchdog-4.16-fixes-2' of git://www.linux-watchdog.org/linux-watchdog:
watchdog: hpwdt: Remove legacy NMI sourcing.
watchdog: sbsa: use 32-bit read for WCV
watchdog: f71808e_wdt: Fix magic close handling

+15 -496
+2 -1
drivers/watchdog/f71808e_wdt.c
··· 566 566 char c; 567 567 if (get_user(c, buf + i)) 568 568 return -EFAULT; 569 - expect_close = (c == 'V'); 569 + if (c == 'V') 570 + expect_close = true; 570 571 } 571 572 572 573 /* Properly order writes across fork()ed processes */
+11 -494
drivers/watchdog/hpwdt.c
··· 28 28 #include <linux/types.h> 29 29 #include <linux/uaccess.h> 30 30 #include <linux/watchdog.h> 31 - #ifdef CONFIG_HPWDT_NMI_DECODING 32 - #include <linux/dmi.h> 33 - #include <linux/spinlock.h> 34 - #include <linux/nmi.h> 35 - #include <linux/kdebug.h> 36 - #include <linux/notifier.h> 37 - #include <asm/set_memory.h> 38 - #endif /* CONFIG_HPWDT_NMI_DECODING */ 39 31 #include <asm/nmi.h> 40 - #include <asm/frame.h> 41 32 42 33 #define HPWDT_VERSION "1.4.0" 43 34 #define SECS_TO_TICKS(secs) ((secs) * 1000 / 128) ··· 39 48 static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */ 40 49 static unsigned int reload; /* the computed soft_margin */ 41 50 static bool nowayout = WATCHDOG_NOWAYOUT; 51 + #ifdef CONFIG_HPWDT_NMI_DECODING 52 + static unsigned int allow_kdump = 1; 53 + #endif 42 54 static char expect_release; 43 55 static unsigned long hpwdt_is_open; 44 56 ··· 57 63 }; 58 64 MODULE_DEVICE_TABLE(pci, hpwdt_devices); 59 65 60 - #ifdef CONFIG_HPWDT_NMI_DECODING 61 - #define PCI_BIOS32_SD_VALUE 0x5F32335F /* "_32_" */ 62 - #define CRU_BIOS_SIGNATURE_VALUE 0x55524324 63 - #define PCI_BIOS32_PARAGRAPH_LEN 16 64 - #define PCI_ROM_BASE1 0x000F0000 65 - #define ROM_SIZE 0x10000 66 - 67 - struct bios32_service_dir { 68 - u32 signature; 69 - u32 entry_point; 70 - u8 revision; 71 - u8 length; 72 - u8 checksum; 73 - u8 reserved[5]; 74 - }; 75 - 76 - /* type 212 */ 77 - struct smbios_cru64_info { 78 - u8 type; 79 - u8 byte_length; 80 - u16 handle; 81 - u32 signature; 82 - u64 physical_address; 83 - u32 double_length; 84 - u32 double_offset; 85 - }; 86 - #define SMBIOS_CRU64_INFORMATION 212 87 - 88 - /* type 219 */ 89 - struct smbios_proliant_info { 90 - u8 type; 91 - u8 byte_length; 92 - u16 handle; 93 - u32 power_features; 94 - u32 omega_features; 95 - u32 reserved; 96 - u32 misc_features; 97 - }; 98 - #define SMBIOS_ICRU_INFORMATION 219 99 - 100 - 101 - struct cmn_registers { 102 - union { 103 - struct { 104 - u8 ral; 105 - u8 rah; 106 - u16 rea2; 107 - }; 108 - u32 reax; 109 - } u1; 110 - union { 111 - struct { 112 - u8 rbl; 113 - u8 rbh; 114 - u8 reb2l; 115 - u8 reb2h; 116 - }; 117 - u32 rebx; 118 - } u2; 119 - union { 120 - struct { 121 - u8 rcl; 122 - u8 rch; 123 - u16 rec2; 124 - }; 125 - u32 recx; 126 - } u3; 127 - union { 128 - struct { 129 - u8 rdl; 130 - u8 rdh; 131 - u16 red2; 132 - }; 133 - u32 redx; 134 - } u4; 135 - 136 - u32 resi; 137 - u32 redi; 138 - u16 rds; 139 - u16 res; 140 - u32 reflags; 141 - } __attribute__((packed)); 142 - 143 - static unsigned int hpwdt_nmi_decoding; 144 - static unsigned int allow_kdump = 1; 145 - static unsigned int is_icru; 146 - static unsigned int is_uefi; 147 - static DEFINE_SPINLOCK(rom_lock); 148 - static void *cru_rom_addr; 149 - static struct cmn_registers cmn_regs; 150 - 151 - extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs, 152 - unsigned long *pRomEntry); 153 - 154 - #ifdef CONFIG_X86_32 155 - /* --32 Bit Bios------------------------------------------------------------ */ 156 - 157 - #define HPWDT_ARCH 32 158 - 159 - asm(".text \n\t" 160 - ".align 4 \n\t" 161 - ".globl asminline_call \n" 162 - "asminline_call: \n\t" 163 - "pushl %ebp \n\t" 164 - "movl %esp, %ebp \n\t" 165 - "pusha \n\t" 166 - "pushf \n\t" 167 - "push %es \n\t" 168 - "push %ds \n\t" 169 - "pop %es \n\t" 170 - "movl 8(%ebp),%eax \n\t" 171 - "movl 4(%eax),%ebx \n\t" 172 - "movl 8(%eax),%ecx \n\t" 173 - "movl 12(%eax),%edx \n\t" 174 - "movl 16(%eax),%esi \n\t" 175 - "movl 20(%eax),%edi \n\t" 176 - "movl (%eax),%eax \n\t" 177 - "push %cs \n\t" 178 - "call *12(%ebp) \n\t" 179 - "pushf \n\t" 180 - "pushl %eax \n\t" 181 - "movl 8(%ebp),%eax \n\t" 182 - "movl %ebx,4(%eax) \n\t" 183 - "movl %ecx,8(%eax) \n\t" 184 - "movl %edx,12(%eax) \n\t" 185 - "movl %esi,16(%eax) \n\t" 186 - "movl %edi,20(%eax) \n\t" 187 - "movw %ds,24(%eax) \n\t" 188 - "movw %es,26(%eax) \n\t" 189 - "popl %ebx \n\t" 190 - "movl %ebx,(%eax) \n\t" 191 - "popl %ebx \n\t" 192 - "movl %ebx,28(%eax) \n\t" 193 - "pop %es \n\t" 194 - "popf \n\t" 195 - "popa \n\t" 196 - "leave \n\t" 197 - "ret \n\t" 198 - ".previous"); 199 - 200 - 201 - /* 202 - * cru_detect 203 - * 204 - * Routine Description: 205 - * This function uses the 32-bit BIOS Service Directory record to 206 - * search for a $CRU record. 207 - * 208 - * Return Value: 209 - * 0 : SUCCESS 210 - * <0 : FAILURE 211 - */ 212 - static int cru_detect(unsigned long map_entry, 213 - unsigned long map_offset) 214 - { 215 - void *bios32_map; 216 - unsigned long *bios32_entrypoint; 217 - unsigned long cru_physical_address; 218 - unsigned long cru_length; 219 - unsigned long physical_bios_base = 0; 220 - unsigned long physical_bios_offset = 0; 221 - int retval = -ENODEV; 222 - 223 - bios32_map = ioremap(map_entry, (2 * PAGE_SIZE)); 224 - 225 - if (bios32_map == NULL) 226 - return -ENODEV; 227 - 228 - bios32_entrypoint = bios32_map + map_offset; 229 - 230 - cmn_regs.u1.reax = CRU_BIOS_SIGNATURE_VALUE; 231 - 232 - set_memory_x((unsigned long)bios32_map, 2); 233 - asminline_call(&cmn_regs, bios32_entrypoint); 234 - 235 - if (cmn_regs.u1.ral != 0) { 236 - pr_warn("Call succeeded but with an error: 0x%x\n", 237 - cmn_regs.u1.ral); 238 - } else { 239 - physical_bios_base = cmn_regs.u2.rebx; 240 - physical_bios_offset = cmn_regs.u4.redx; 241 - cru_length = cmn_regs.u3.recx; 242 - cru_physical_address = 243 - physical_bios_base + physical_bios_offset; 244 - 245 - /* If the values look OK, then map it in. */ 246 - if ((physical_bios_base + physical_bios_offset)) { 247 - cru_rom_addr = 248 - ioremap(cru_physical_address, cru_length); 249 - if (cru_rom_addr) { 250 - set_memory_x((unsigned long)cru_rom_addr & PAGE_MASK, 251 - (cru_length + PAGE_SIZE - 1) >> PAGE_SHIFT); 252 - retval = 0; 253 - } 254 - } 255 - 256 - pr_debug("CRU Base Address: 0x%lx\n", physical_bios_base); 257 - pr_debug("CRU Offset Address: 0x%lx\n", physical_bios_offset); 258 - pr_debug("CRU Length: 0x%lx\n", cru_length); 259 - pr_debug("CRU Mapped Address: %p\n", &cru_rom_addr); 260 - } 261 - iounmap(bios32_map); 262 - return retval; 263 - } 264 - 265 - /* 266 - * bios_checksum 267 - */ 268 - static int bios_checksum(const char __iomem *ptr, int len) 269 - { 270 - char sum = 0; 271 - int i; 272 - 273 - /* 274 - * calculate checksum of size bytes. This should add up 275 - * to zero if we have a valid header. 276 - */ 277 - for (i = 0; i < len; i++) 278 - sum += ptr[i]; 279 - 280 - return ((sum == 0) && (len > 0)); 281 - } 282 - 283 - /* 284 - * bios32_present 285 - * 286 - * Routine Description: 287 - * This function finds the 32-bit BIOS Service Directory 288 - * 289 - * Return Value: 290 - * 0 : SUCCESS 291 - * <0 : FAILURE 292 - */ 293 - static int bios32_present(const char __iomem *p) 294 - { 295 - struct bios32_service_dir *bios_32_ptr; 296 - int length; 297 - unsigned long map_entry, map_offset; 298 - 299 - bios_32_ptr = (struct bios32_service_dir *) p; 300 - 301 - /* 302 - * Search for signature by checking equal to the swizzled value 303 - * instead of calling another routine to perform a strcmp. 304 - */ 305 - if (bios_32_ptr->signature == PCI_BIOS32_SD_VALUE) { 306 - length = bios_32_ptr->length * PCI_BIOS32_PARAGRAPH_LEN; 307 - if (bios_checksum(p, length)) { 308 - /* 309 - * According to the spec, we're looking for the 310 - * first 4KB-aligned address below the entrypoint 311 - * listed in the header. The Service Directory code 312 - * is guaranteed to occupy no more than 2 4KB pages. 313 - */ 314 - map_entry = bios_32_ptr->entry_point & ~(PAGE_SIZE - 1); 315 - map_offset = bios_32_ptr->entry_point - map_entry; 316 - 317 - return cru_detect(map_entry, map_offset); 318 - } 319 - } 320 - return -ENODEV; 321 - } 322 - 323 - static int detect_cru_service(void) 324 - { 325 - char __iomem *p, *q; 326 - int rc = -1; 327 - 328 - /* 329 - * Search from 0x0f0000 through 0x0fffff, inclusive. 330 - */ 331 - p = ioremap(PCI_ROM_BASE1, ROM_SIZE); 332 - if (p == NULL) 333 - return -ENOMEM; 334 - 335 - for (q = p; q < p + ROM_SIZE; q += 16) { 336 - rc = bios32_present(q); 337 - if (!rc) 338 - break; 339 - } 340 - iounmap(p); 341 - return rc; 342 - } 343 - /* ------------------------------------------------------------------------- */ 344 - #endif /* CONFIG_X86_32 */ 345 - #ifdef CONFIG_X86_64 346 - /* --64 Bit Bios------------------------------------------------------------ */ 347 - 348 - #define HPWDT_ARCH 64 349 - 350 - asm(".text \n\t" 351 - ".align 4 \n\t" 352 - ".globl asminline_call \n\t" 353 - ".type asminline_call, @function \n\t" 354 - "asminline_call: \n\t" 355 - FRAME_BEGIN 356 - "pushq %rax \n\t" 357 - "pushq %rbx \n\t" 358 - "pushq %rdx \n\t" 359 - "pushq %r12 \n\t" 360 - "pushq %r9 \n\t" 361 - "movq %rsi, %r12 \n\t" 362 - "movq %rdi, %r9 \n\t" 363 - "movl 4(%r9),%ebx \n\t" 364 - "movl 8(%r9),%ecx \n\t" 365 - "movl 12(%r9),%edx \n\t" 366 - "movl 16(%r9),%esi \n\t" 367 - "movl 20(%r9),%edi \n\t" 368 - "movl (%r9),%eax \n\t" 369 - "call *%r12 \n\t" 370 - "pushfq \n\t" 371 - "popq %r12 \n\t" 372 - "movl %eax, (%r9) \n\t" 373 - "movl %ebx, 4(%r9) \n\t" 374 - "movl %ecx, 8(%r9) \n\t" 375 - "movl %edx, 12(%r9) \n\t" 376 - "movl %esi, 16(%r9) \n\t" 377 - "movl %edi, 20(%r9) \n\t" 378 - "movq %r12, %rax \n\t" 379 - "movl %eax, 28(%r9) \n\t" 380 - "popq %r9 \n\t" 381 - "popq %r12 \n\t" 382 - "popq %rdx \n\t" 383 - "popq %rbx \n\t" 384 - "popq %rax \n\t" 385 - FRAME_END 386 - "ret \n\t" 387 - ".previous"); 388 - 389 - /* 390 - * dmi_find_cru 391 - * 392 - * Routine Description: 393 - * This function checks whether or not a SMBIOS/DMI record is 394 - * the 64bit CRU info or not 395 - */ 396 - static void dmi_find_cru(const struct dmi_header *dm, void *dummy) 397 - { 398 - struct smbios_cru64_info *smbios_cru64_ptr; 399 - unsigned long cru_physical_address; 400 - 401 - if (dm->type == SMBIOS_CRU64_INFORMATION) { 402 - smbios_cru64_ptr = (struct smbios_cru64_info *) dm; 403 - if (smbios_cru64_ptr->signature == CRU_BIOS_SIGNATURE_VALUE) { 404 - cru_physical_address = 405 - smbios_cru64_ptr->physical_address + 406 - smbios_cru64_ptr->double_offset; 407 - cru_rom_addr = ioremap(cru_physical_address, 408 - smbios_cru64_ptr->double_length); 409 - set_memory_x((unsigned long)cru_rom_addr & PAGE_MASK, 410 - smbios_cru64_ptr->double_length >> PAGE_SHIFT); 411 - } 412 - } 413 - } 414 - 415 - static int detect_cru_service(void) 416 - { 417 - cru_rom_addr = NULL; 418 - 419 - dmi_walk(dmi_find_cru, NULL); 420 - 421 - /* if cru_rom_addr has been set then we found a CRU service */ 422 - return ((cru_rom_addr != NULL) ? 0 : -ENODEV); 423 - } 424 - /* ------------------------------------------------------------------------- */ 425 - #endif /* CONFIG_X86_64 */ 426 - #endif /* CONFIG_HPWDT_NMI_DECODING */ 427 66 428 67 /* 429 68 * Watchdog operations ··· 113 486 */ 114 487 static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) 115 488 { 116 - unsigned long rom_pl; 117 - static int die_nmi_called; 118 - 119 - if (!hpwdt_nmi_decoding) 120 - return NMI_DONE; 121 - 122 489 if ((ulReason == NMI_UNKNOWN) && !hpwdt_my_nmi()) 123 490 return NMI_DONE; 124 - 125 - spin_lock_irqsave(&rom_lock, rom_pl); 126 - if (!die_nmi_called && !is_icru && !is_uefi) 127 - asminline_call(&cmn_regs, cru_rom_addr); 128 - die_nmi_called = 1; 129 - spin_unlock_irqrestore(&rom_lock, rom_pl); 130 491 131 492 if (allow_kdump) 132 493 hpwdt_stop(); 133 494 134 - if (!is_icru && !is_uefi) { 135 - if (cmn_regs.u1.ral == 0) { 136 - nmi_panic(regs, "An NMI occurred, but unable to determine source.\n"); 137 - return NMI_HANDLED; 138 - } 139 - } 140 495 nmi_panic(regs, "An NMI occurred. Depending on your system the reason " 141 496 "for the NMI is logged in any one of the following " 142 497 "resources:\n" ··· 284 675 * Init & Exit 285 676 */ 286 677 287 - #ifdef CONFIG_HPWDT_NMI_DECODING 288 - #ifdef CONFIG_X86_LOCAL_APIC 289 - static void hpwdt_check_nmi_decoding(struct pci_dev *dev) 290 - { 291 - /* 292 - * If nmi_watchdog is turned off then we can turn on 293 - * our nmi decoding capability. 294 - */ 295 - hpwdt_nmi_decoding = 1; 296 - } 297 - #else 298 - static void hpwdt_check_nmi_decoding(struct pci_dev *dev) 299 - { 300 - dev_warn(&dev->dev, "NMI decoding is disabled. " 301 - "Your kernel does not support a NMI Watchdog.\n"); 302 - } 303 - #endif /* CONFIG_X86_LOCAL_APIC */ 304 - 305 - /* 306 - * dmi_find_icru 307 - * 308 - * Routine Description: 309 - * This function checks whether or not we are on an iCRU-based server. 310 - * This check is independent of architecture and needs to be made for 311 - * any ProLiant system. 312 - */ 313 - static void dmi_find_icru(const struct dmi_header *dm, void *dummy) 314 - { 315 - struct smbios_proliant_info *smbios_proliant_ptr; 316 - 317 - if (dm->type == SMBIOS_ICRU_INFORMATION) { 318 - smbios_proliant_ptr = (struct smbios_proliant_info *) dm; 319 - if (smbios_proliant_ptr->misc_features & 0x01) 320 - is_icru = 1; 321 - if (smbios_proliant_ptr->misc_features & 0x1400) 322 - is_uefi = 1; 323 - } 324 - } 325 678 326 679 static int hpwdt_init_nmi_decoding(struct pci_dev *dev) 327 680 { 681 + #ifdef CONFIG_HPWDT_NMI_DECODING 328 682 int retval; 329 - 330 - /* 331 - * On typical CRU-based systems we need to map that service in 332 - * the BIOS. For 32 bit Operating Systems we need to go through 333 - * the 32 Bit BIOS Service Directory. For 64 bit Operating 334 - * Systems we get that service through SMBIOS. 335 - * 336 - * On systems that support the new iCRU service all we need to 337 - * do is call dmi_walk to get the supported flag value and skip 338 - * the old cru detect code. 339 - */ 340 - dmi_walk(dmi_find_icru, NULL); 341 - if (!is_icru && !is_uefi) { 342 - 343 - /* 344 - * We need to map the ROM to get the CRU service. 345 - * For 32 bit Operating Systems we need to go through the 32 Bit 346 - * BIOS Service Directory 347 - * For 64 bit Operating Systems we get that service through SMBIOS. 348 - */ 349 - retval = detect_cru_service(); 350 - if (retval < 0) { 351 - dev_warn(&dev->dev, 352 - "Unable to detect the %d Bit CRU Service.\n", 353 - HPWDT_ARCH); 354 - return retval; 355 - } 356 - 357 - /* 358 - * We know this is the only CRU call we need to make so lets keep as 359 - * few instructions as possible once the NMI comes in. 360 - */ 361 - cmn_regs.u1.rah = 0x0D; 362 - cmn_regs.u1.ral = 0x02; 363 - } 364 - 365 683 /* 366 684 * Only one function can register for NMI_UNKNOWN 367 685 */ ··· 316 780 dev_warn(&dev->dev, 317 781 "Unable to register a die notifier (err=%d).\n", 318 782 retval); 319 - if (cru_rom_addr) 320 - iounmap(cru_rom_addr); 321 783 return retval; 322 - } 323 - 324 - static void hpwdt_exit_nmi_decoding(void) 325 - { 326 - unregister_nmi_handler(NMI_UNKNOWN, "hpwdt"); 327 - unregister_nmi_handler(NMI_SERR, "hpwdt"); 328 - unregister_nmi_handler(NMI_IO_CHECK, "hpwdt"); 329 - if (cru_rom_addr) 330 - iounmap(cru_rom_addr); 331 - } 332 - #else /* !CONFIG_HPWDT_NMI_DECODING */ 333 - static void hpwdt_check_nmi_decoding(struct pci_dev *dev) 334 - { 335 - } 336 - 337 - static int hpwdt_init_nmi_decoding(struct pci_dev *dev) 338 - { 784 + #endif /* CONFIG_HPWDT_NMI_DECODING */ 339 785 return 0; 340 786 } 341 787 342 788 static void hpwdt_exit_nmi_decoding(void) 343 789 { 790 + #ifdef CONFIG_HPWDT_NMI_DECODING 791 + unregister_nmi_handler(NMI_UNKNOWN, "hpwdt"); 792 + unregister_nmi_handler(NMI_SERR, "hpwdt"); 793 + unregister_nmi_handler(NMI_IO_CHECK, "hpwdt"); 794 + #endif 344 795 } 345 - #endif /* CONFIG_HPWDT_NMI_DECODING */ 346 796 347 797 static int hpwdt_init_one(struct pci_dev *dev, 348 798 const struct pci_device_id *ent) 349 799 { 350 800 int retval; 351 - 352 - /* 353 - * Check if we can do NMI decoding or not 354 - */ 355 - hpwdt_check_nmi_decoding(dev); 356 801 357 802 /* 358 803 * First let's find out if we are on an iLO2+ server. We will ··· 439 922 #ifdef CONFIG_HPWDT_NMI_DECODING 440 923 module_param(allow_kdump, int, 0); 441 924 MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs"); 442 - #endif /* !CONFIG_HPWDT_NMI_DECODING */ 925 + #endif /* CONFIG_HPWDT_NMI_DECODING */ 443 926 444 927 module_pci_driver(hpwdt_driver);
+2 -1
drivers/watchdog/sbsa_gwdt.c
··· 50 50 */ 51 51 52 52 #include <linux/io.h> 53 + #include <linux/io-64-nonatomic-lo-hi.h> 53 54 #include <linux/interrupt.h> 54 55 #include <linux/module.h> 55 56 #include <linux/moduleparam.h> ··· 160 159 !(readl(gwdt->control_base + SBSA_GWDT_WCS) & SBSA_GWDT_WCS_WS0)) 161 160 timeleft += readl(gwdt->control_base + SBSA_GWDT_WOR); 162 161 163 - timeleft += readq(gwdt->control_base + SBSA_GWDT_WCV) - 162 + timeleft += lo_hi_readq(gwdt->control_base + SBSA_GWDT_WCV) - 164 163 arch_counter_get_cntvct(); 165 164 166 165 do_div(timeleft, gwdt->clk);