arch/s390/kvm/gaccess.h

Source file repositories/reference/linux-study-clean/arch/s390/kvm/gaccess.h

File Facts

System
Linux kernel
Corpus path
arch/s390/kvm/gaccess.h
Extension
.h
Size
16423 bytes
Lines
467
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef __KVM_S390_GACCESS_H
#define __KVM_S390_GACCESS_H

#include <linux/compiler.h>
#include <linux/kvm_host.h>
#include <linux/uaccess.h>
#include <linux/ptrace.h>
#include "kvm-s390.h"

/**
 * kvm_s390_real_to_abs - convert guest real address to guest absolute address
 * @prefix - guest prefix
 * @gra - guest real address
 *
 * Returns the guest absolute address that corresponds to the passed guest real
 * address @gra of by applying the given prefix.
 */
static inline unsigned long _kvm_s390_real_to_abs(u32 prefix, unsigned long gra)
{
	if (gra < 2 * PAGE_SIZE)
		gra += prefix;
	else if (gra >= prefix && gra < prefix + 2 * PAGE_SIZE)
		gra -= prefix;
	return gra;
}

/**
 * kvm_s390_real_to_abs - convert guest real address to guest absolute address
 * @vcpu - guest virtual cpu
 * @gra - guest real address
 *
 * Returns the guest absolute address that corresponds to the passed guest real
 * address @gra of a virtual guest cpu by applying its prefix.
 */
static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
						 unsigned long gra)
{
	return _kvm_s390_real_to_abs(kvm_s390_get_prefix(vcpu), gra);
}

/**
 * _kvm_s390_logical_to_effective - convert guest logical to effective address
 * @psw: psw of the guest
 * @ga: guest logical address
 *
 * Convert a guest logical address to an effective address by applying the
 * rules of the addressing mode defined by bits 31 and 32 of the given PSW
 * (extendended/basic addressing mode).
 *
 * Depending on the addressing mode, the upper 40 bits (24 bit addressing
 * mode), 33 bits (31 bit addressing mode) or no bits (64 bit addressing
 * mode) of @ga will be zeroed and the remaining bits will be returned.
 */
static inline unsigned long _kvm_s390_logical_to_effective(psw_t *psw,
							   unsigned long ga)
{
	if (psw_bits(*psw).eaba == PSW_BITS_AMODE_64BIT)
		return ga;
	if (psw_bits(*psw).eaba == PSW_BITS_AMODE_31BIT)
		return ga & ((1UL << 31) - 1);
	return ga & ((1UL << 24) - 1);
}

/**
 * kvm_s390_logical_to_effective - convert guest logical to effective address
 * @vcpu: guest virtual cpu
 * @ga: guest logical address
 *
 * Convert a guest vcpu logical address to a guest vcpu effective address by
 * applying the rules of the vcpu's addressing mode defined by PSW bits 31
 * and 32 (extendended/basic addressing mode).
 *
 * Depending on the vcpu's addressing mode the upper 40 bits (24 bit addressing
 * mode), 33 bits (31 bit addressing mode) or no bits (64 bit addressing mode)
 * of @ga will be zeroed and the remaining bits will be returned.
 */
static inline unsigned long kvm_s390_logical_to_effective(struct kvm_vcpu *vcpu,
							  unsigned long ga)
{
	return _kvm_s390_logical_to_effective(&vcpu->arch.sie_block->gpsw, ga);
}

/*
 * put_guest_lc, read_guest_lc and write_guest_lc are guest access functions
 * which shall only be used to access the lowcore of a vcpu.
 * These functions should be used for e.g. interrupt handlers where no
 * guest memory access protection facilities, like key or low address
 * protection, are applicable.
 * At a later point guest vcpu lowcore access should happen via pinned
 * prefix pages, so that these pages can be accessed directly via the

Annotation

Implementation Notes