<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-dev/arch/riscv/kernel/asm-offsets.c, branch linus/master</title>
<subtitle>Linux kernel development work - see feature branches</subtitle>
<id>https://git.zx2c4.com/linux-dev/atom/arch/riscv/kernel/asm-offsets.c?h=linus%2Fmaster</id>
<link rel='self' href='https://git.zx2c4.com/linux-dev/atom/arch/riscv/kernel/asm-offsets.c?h=linus%2Fmaster'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/'/>
<updated>2022-03-10T17:29:31Z</updated>
<entry>
<title>RISC-V: Add arch functions for non-retentive suspend entry/exit</title>
<updated>2022-03-10T17:29:31Z</updated>
<author>
<name>Anup Patel</name>
<email>anup.patel@wdc.com</email>
</author>
<published>2022-02-10T05:49:42Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=63b13e64a829e7b12fba81fccbea0d5448fc0c24'/>
<id>urn:sha1:63b13e64a829e7b12fba81fccbea0d5448fc0c24</id>
<content type='text'>
The hart registers and CSRs are not preserved in non-retentative
suspend state so we provide arch specific helper functions which
will save/restore hart context upon entry/exit to non-retentive
suspend state. These helper functions can be used by cpuidle
drivers for non-retentive suspend entry/exit.

Signed-off-by: Anup Patel &lt;anup.patel@wdc.com&gt;
Signed-off-by: Anup Patel &lt;apatel@ventanamicro.com&gt;
Reviewed-by: Guo Ren &lt;guoren@kernel.org&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>RISC-V: Avoid using per cpu array for ordered booting</title>
<updated>2022-01-20T17:26:59Z</updated>
<author>
<name>Atish Patra</name>
<email>atishp@rivosinc.com</email>
</author>
<published>2022-01-20T09:09:13Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=9a2451f1866344d38b4a1dc20396e3a03954fcd7'/>
<id>urn:sha1:9a2451f1866344d38b4a1dc20396e3a03954fcd7</id>
<content type='text'>
Currently both order booting and spinwait approach uses a per cpu
array to update stack &amp; task pointer. This approach will not work for the
following cases.
1. If NR_CPUs are configured to be less than highest hart id.
2. A platform has sparse hartid.

This issue can be fixed for ordered booting as the booting cpu brings up
one cpu at a time using SBI HSM extension which has opaque parameter
that is unused until now.

Introduce a common secondary boot data structure that can store the stack
and task pointer. Secondary harts will use this data while booting up
to setup the sp &amp; tp.

Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Signed-off-by: Atish Patra &lt;atishp@rivosinc.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm</title>
<updated>2021-11-02T18:24:14Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-11-02T18:24:14Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=d7e0a795bf37a13554c80cfc5ba97abedf53f391'/>
<id>urn:sha1:d7e0a795bf37a13554c80cfc5ba97abedf53f391</id>
<content type='text'>
Pull KVM updates from Paolo Bonzini:
 "ARM:

   - More progress on the protected VM front, now with the full fixed
     feature set as well as the limitation of some hypercalls after
     initialisation.

   - Cleanup of the RAZ/WI sysreg handling, which was pointlessly
     complicated

   - Fixes for the vgic placement in the IPA space, together with a
     bunch of selftests

   - More memcg accounting of the memory allocated on behalf of a guest

   - Timer and vgic selftests

   - Workarounds for the Apple M1 broken vgic implementation

   - KConfig cleanups

   - New kvmarm.mode=none option, for those who really dislike us

  RISC-V:

   - New KVM port.

  x86:

   - New API to control TSC offset from userspace

   - TSC scaling for nested hypervisors on SVM

   - Switch masterclock protection from raw_spin_lock to seqcount

   - Clean up function prototypes in the page fault code and avoid
     repeated memslot lookups

   - Convey the exit reason to userspace on emulation failure

   - Configure time between NX page recovery iterations

   - Expose Predictive Store Forwarding Disable CPUID leaf

   - Allocate page tracking data structures lazily (if the i915 KVM-GT
     functionality is not compiled in)

   - Cleanups, fixes and optimizations for the shadow MMU code

  s390:

   - SIGP Fixes

   - initial preparations for lazy destroy of secure VMs

   - storage key improvements/fixes

   - Log the guest CPNC

  Starting from this release, KVM-PPC patches will come from Michael
  Ellerman's PPC tree"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (227 commits)
  RISC-V: KVM: fix boolreturn.cocci warnings
  RISC-V: KVM: remove unneeded semicolon
  RISC-V: KVM: Fix GPA passed to __kvm_riscv_hfence_gvma_xyz() functions
  RISC-V: KVM: Factor-out FP virtualization into separate sources
  KVM: s390: add debug statement for diag 318 CPNC data
  KVM: s390: pv: properly handle page flags for protected guests
  KVM: s390: Fix handle_sske page fault handling
  KVM: x86: SGX must obey the KVM_INTERNAL_ERROR_EMULATION protocol
  KVM: x86: On emulation failure, convey the exit reason, etc. to userspace
  KVM: x86: Get exit_reason as part of kvm_x86_ops.get_exit_info
  KVM: x86: Clarify the kvm_run.emulation_failure structure layout
  KVM: s390: Add a routine for setting userspace CPU state
  KVM: s390: Simplify SIGP Set Arch handling
  KVM: s390: pv: avoid stalls when making pages secure
  KVM: s390: pv: avoid stalls for kvm_s390_pv_init_vm
  KVM: s390: pv: avoid double free of sida page
  KVM: s390: pv: add macros for UVC CC values
  s390/mm: optimize reset_guest_reference_bit()
  s390/mm: optimize set_guest_storage_key()
  s390/mm: no need for pte_alloc_map_lock() if we know the pmd is present
  ...
</content>
</entry>
<entry>
<title>RISC-V: KVM: FP lazy save/restore</title>
<updated>2021-10-04T10:38:23Z</updated>
<author>
<name>Atish Patra</name>
<email>atish.patra@wdc.com</email>
</author>
<published>2021-09-27T11:40:12Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=5de52d4a23ad3346c3cb24aae728ef6642d1a92e'/>
<id>urn:sha1:5de52d4a23ad3346c3cb24aae728ef6642d1a92e</id>
<content type='text'>
This patch adds floating point (F and D extension) context save/restore
for guest VCPUs. The FP context is saved and restored lazily only when
kernel enter/exits the in-kernel run loop and not during the KVM world
switch. This way FP save/restore has minimal impact on KVM performance.

Signed-off-by: Atish Patra &lt;atish.patra@wdc.com&gt;
Signed-off-by: Anup Patel &lt;anup.patel@wdc.com&gt;
Acked-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Acked-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Handle MMIO exits for VCPU</title>
<updated>2021-10-04T10:21:47Z</updated>
<author>
<name>Anup Patel</name>
<email>anup.patel@wdc.com</email>
</author>
<published>2021-09-27T11:40:06Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=9f7013265112a92340cef5debec8d02ec8d1de06'/>
<id>urn:sha1:9f7013265112a92340cef5debec8d02ec8d1de06</id>
<content type='text'>
We will get stage2 page faults whenever Guest/VM access SW emulated
MMIO device or unmapped Guest RAM.

This patch implements MMIO read/write emulation by extracting MMIO
details from the trapped load/store instruction and forwarding the
MMIO read/write to user-space. The actual MMIO emulation will happen
in user-space and KVM kernel module will only take care of register
updates before resuming the trapped VCPU.

The handling for stage2 page faults for unmapped Guest RAM will be
implemeted by a separate patch later.

[jiangyifei: ioeventfd and in-kernel mmio device support]
Signed-off-by: Yifei Jiang &lt;jiangyifei@huawei.com&gt;
Signed-off-by: Anup Patel &lt;anup.patel@wdc.com&gt;
Acked-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Acked-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>RISC-V: KVM: Implement VCPU world-switch</title>
<updated>2021-10-04T10:19:57Z</updated>
<author>
<name>Anup Patel</name>
<email>anup.patel@wdc.com</email>
</author>
<published>2021-09-27T11:40:05Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=34bde9d8b9e6e5249db3c07cf1ebfe75c23c671c'/>
<id>urn:sha1:34bde9d8b9e6e5249db3c07cf1ebfe75c23c671c</id>
<content type='text'>
This patch implements the VCPU world-switch for KVM RISC-V.

The KVM RISC-V world-switch (i.e. __kvm_riscv_switch_to()) mostly
switches general purpose registers, SSTATUS, STVEC, SSCRATCH and
HSTATUS CSRs. Other CSRs are switched via vcpu_load() and vcpu_put()
interface in kvm_arch_vcpu_load() and kvm_arch_vcpu_put() functions
respectively.

Signed-off-by: Anup Patel &lt;anup.patel@wdc.com&gt;
Acked-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Acked-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: rely on core code to keep thread_info::cpu updated</title>
<updated>2021-09-30T14:13:11Z</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ardb@kernel.org</email>
</author>
<published>2021-09-14T12:10:35Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=8aa0fb0fbb82a4d2395be7eaeb994653b2d869fc'/>
<id>urn:sha1:8aa0fb0fbb82a4d2395be7eaeb994653b2d869fc</id>
<content type='text'>
Now that the core code switched back to using thread_info::cpu to keep
a task's CPU number, we no longer need to keep it in sync explicitly. So
just drop the code that does this.

Signed-off-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Acked-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
Acked-by: Mark Rutland &lt;mark.rutland@arm.com&gt;
</content>
</entry>
<entry>
<title>riscv: Introduce structure that group all variables regarding kernel mapping</title>
<updated>2021-07-06T01:04:00Z</updated>
<author>
<name>Alexandre Ghiti</name>
<email>alex@ghiti.fr</email>
</author>
<published>2021-06-17T13:53:07Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=658e2c5125bbbc9b9b5eac23b3c35b87df3c30b8'/>
<id>urn:sha1:658e2c5125bbbc9b9b5eac23b3c35b87df3c30b8</id>
<content type='text'>
We have a lot of variables that are used to hold kernel mapping addresses,
offsets between physical and virtual mappings and some others used for XIP
kernels: they are all defined at different places in mm/init.c, so group
them into a single structure with, for some of them, more explicit and concise
names.

Signed-off-by: Alexandre Ghiti &lt;alex@ghiti.fr&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: Enable per-task stack canaries</title>
<updated>2021-01-14T23:09:10Z</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-12-17T16:29:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=fea2fed201ee5647699018a56fbb6a5e8cc053a5'/>
<id>urn:sha1:fea2fed201ee5647699018a56fbb6a5e8cc053a5</id>
<content type='text'>
This enables the use of per-task stack canary values if GCC has
support for emitting the stack canary reference relative to the
value of tp, which holds the task struct pointer in the riscv
kernel.

After compare arm64 and x86 implementations, seems arm64's is more
flexible and readable. The key point is how gcc get the offset of
stack_canary from gs/el0_sp.

x86: Use a fix offset from gs, not flexible.

struct fixed_percpu_data {
	/*
	 * GCC hardcodes the stack canary as %gs:40.  Since the
	 * irq_stack is the object at %gs:0, we reserve the bottom
	 * 48 bytes of the irq stack for the canary.
	 */
	char            gs_base[40]; // :(
	unsigned long   stack_canary;
};

arm64: Use -mstack-protector-guard-offset &amp; guard-reg
	gcc options:
	-mstack-protector-guard=sysreg
	-mstack-protector-guard-reg=sp_el0
	-mstack-protector-guard-offset=xxx

riscv: Use -mstack-protector-guard-offset &amp; guard-reg
	gcc options:
	-mstack-protector-guard=tls
	-mstack-protector-guard-reg=tp
	-mstack-protector-guard-offset=xxx

 GCC's implementation has been merged:
 commit c931e8d5a96463427040b0d11f9c4352ac22b2b0
 Author: Cooper Qu &lt;cooper.qu@linux.alibaba.com&gt;
 Date:   Mon Jul 13 16:15:08 2020 +0800

     RISC-V: Add support for TLS stack protector canary access

In the end, these codes are inserted by gcc before return:

*  0xffffffe00020b396 &lt;+120&gt;:   ld      a5,1008(tp) # 0x3f0
*  0xffffffe00020b39a &lt;+124&gt;:   xor     a5,a5,a4
*  0xffffffe00020b39c &lt;+126&gt;:   mv      a0,s5
*  0xffffffe00020b39e &lt;+128&gt;:   bnez    a5,0xffffffe00020b61c &lt;_do_fork+766&gt;
   0xffffffe00020b3a2 &lt;+132&gt;:   ld      ra,136(sp)
   0xffffffe00020b3a4 &lt;+134&gt;:   ld      s0,128(sp)
   0xffffffe00020b3a6 &lt;+136&gt;:   ld      s1,120(sp)
   0xffffffe00020b3a8 &lt;+138&gt;:   ld      s2,112(sp)
   0xffffffe00020b3aa &lt;+140&gt;:   ld      s3,104(sp)
   0xffffffe00020b3ac &lt;+142&gt;:   ld      s4,96(sp)
   0xffffffe00020b3ae &lt;+144&gt;:   ld      s5,88(sp)
   0xffffffe00020b3b0 &lt;+146&gt;:   ld      s6,80(sp)
   0xffffffe00020b3b2 &lt;+148&gt;:   ld      s7,72(sp)
   0xffffffe00020b3b4 &lt;+150&gt;:   addi    sp,sp,144
   0xffffffe00020b3b6 &lt;+152&gt;:   ret
   ...
*  0xffffffe00020b61c &lt;+766&gt;:   auipc   ra,0x7f8
*  0xffffffe00020b620 &lt;+770&gt;:   jalr    -1764(ra) # 0xffffffe000a02f38 &lt;__stack_chk_fail&gt;

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Signed-off-by: Cooper Qu &lt;cooper.qu@linux.alibaba.com&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv: Fixed kernel test robot warning</title>
<updated>2020-12-11T01:47:23Z</updated>
<author>
<name>Souptick Joarder</name>
<email>jrdr.linux@gmail.com</email>
</author>
<published>2020-12-08T19:27:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=3ae9c3cde51abcb777125cfcf74cc402f4d0a4c7'/>
<id>urn:sha1:3ae9c3cde51abcb777125cfcf74cc402f4d0a4c7</id>
<content type='text'>
Kernel test robot throws below warning -

   arch/riscv/kernel/asm-offsets.c:14:6: warning: no previous prototype
for 'asm_offsets' [-Wmissing-prototypes]
      14 | void asm_offsets(void)
         |      ^~~~~~~~~~~

This patch should fixed it.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Souptick Joarder &lt;jrdr.linux@gmail.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
</feed>
