1

I have a workstation using Hygon C86 7280 CPU, /proc/cpuinfo shows it has 43 physical address bits, and 48 virtual address bit.
But when I mmap a BAR of PCI device (via /sys/bus/pci/devices/0000:nn:00.0/resource0), I can only read 0xffffffff from that mapping.
From the output of crash vtop, it shows the mapping is as follows,

PTE:    f8bd3B800  => 80008000DDE20237

To my surprise, bit47 in PTE is '1'! I think it should be '0' as the reserved bits.
I am not sure if my understanding is right or not. Why reserved bit of 47 is set in this case?

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
wangt13
  • 959
  • 7
  • 17
  • The crash is the crash utility used in Linux to do live debugging in this case. The application mapping this BAR does NOT crash but can only read 0xfffffff from the mapped BAR. I did NOT find Hygon manual, so I don't know its detail. You mentioned canonical virtual address, I am NOT sure if it also needs physical address to be canonical, I think the data in PTE is physical page frame number, should it also need to be canonical? If so, that should be a bad/invalid PTE, but crash utility does NOT complain about that...... – wangt13 Mar 19 '22 at 00:23
  • My bad, scrap my previous comment, I was under the impression that the addresses you show were the translation `pa => va`. Yeah the PTE seems bogus as you say since bit 47 should be reserved and set to 0. Did you test your code on Intel/AMD? Could be a problem that only appears on Hygon. Nonetheless, difficult to say without a [mre] stating the steps needed to reproduce the problem nor a manual (seems impossible to find one online). Linux does not seem to have any definition for that bit anyway (https://elixir.bootlin.com/linux/v5.16.15/source/arch/x86/include/asm/pgtable_types.h#L10). – Marco Bonelli Mar 19 '22 at 00:46
  • The application can work well in Intel system, and bit47 is 0 in a system with 46 physical address bits. It has NOT been tested in AMD system, so does NOT know the result. Kernel codes can read BAR data well, but application cannot do that. I think there should be something special in Hygon + Linux which causes the strange PTE. Do you know where can I get Hygon manual to find the PTE descrption? – wangt13 Mar 19 '22 at 01:15
  • I wish I knew... honestly I think your best bet is to just message a seller on ebay/aliexpress/whatever and ask for the manual :') at least that's what I do for weird Chinese chips. OR you could try writing on the kernel x86 mailing list or to the author of the original patches for Hygon (e.g. see https://lore.kernel.org/lkml/cover.1536550549.git.puwen@hygon.cn/). – Marco Bonelli Mar 19 '22 at 03:12
  • By upgrading OS, the problem is fixed, bad news. I don't know the root cause since the problem cannot be reproduced. I am keeping eyes on it, and update here if there is anything new. – wangt13 Mar 21 '22 at 08:16

0 Answers0