cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

vsx_asm.S (1359B)


      1/* SPDX-License-Identifier: GPL-2.0-or-later */
      2/*
      3 * Copyright 2015, Cyril Bur, IBM Corp.
      4 */
      5
      6#include "basic_asm.h"
      7#include "vsx_asm.h"
      8
      9#long check_vsx(vector int *r3);
     10#This function wraps storeing VSX regs to the end of an array and a
     11#call to a comparison function in C which boils down to a memcmp()
     12FUNC_START(check_vsx)
     13	PUSH_BASIC_STACK(32)
     14	std	r3,STACK_FRAME_PARAM(0)(sp)
     15	addi r3, r3, 16 * 12 #Second half of array
     16	bl store_vsx
     17	ld r3,STACK_FRAME_PARAM(0)(sp)
     18	bl vsx_memcmp
     19	POP_BASIC_STACK(32)
     20	blr
     21FUNC_END(check_vsx)
     22
     23# int preempt_vmx(vector int *varray, int *threads_starting,
     24#                 int *running);
     25# On starting will (atomically) decrement threads_starting as a signal
     26# that the VMX have been loaded with varray. Will proceed to check the
     27# validity of the VMX registers while running is not zero.
     28FUNC_START(preempt_vsx)
     29	PUSH_BASIC_STACK(512)
     30	std r3,STACK_FRAME_PARAM(0)(sp) # vector int *varray
     31	std r4,STACK_FRAME_PARAM(1)(sp) # int *threads_starting
     32	std r5,STACK_FRAME_PARAM(2)(sp) # int *running
     33
     34	bl load_vsx
     35	nop
     36
     37	sync
     38	# Atomic DEC
     39	ld r3,STACK_FRAME_PARAM(1)(sp)
     401:	lwarx r4,0,r3
     41	addi r4,r4,-1
     42	stwcx. r4,0,r3
     43	bne- 1b
     44
     452:	ld r3,STACK_FRAME_PARAM(0)(sp)
     46	bl check_vsx
     47	nop
     48	cmpdi r3,0
     49	bne 3f
     50	ld r4,STACK_FRAME_PARAM(2)(sp)
     51	ld r5,0(r4)
     52	cmpwi r5,0
     53	bne 2b
     54
     553:	POP_BASIC_STACK(512)
     56	blr
     57FUNC_END(preempt_vsx)