Re: [PATCH v2] KVM: s390: gaccess: Refactor access address range check
From: Janis Schoetterl-Glausch
Date: Fri Nov 19 2021 - 05:02:15 EST
On 11/19/21 09:56, Janosch Frank wrote:
> On 10/28/21 15:55, Janis Schoetterl-Glausch wrote:
>> Do not round down the first address to the page boundary, just translate
>> it normally, which gives the value we care about in the first place.
>> Given this, translating a single address is just the special case of
>> translating a range spanning a single page.
>> Make the output optional, so the function can be used to just check a
>> Signed-off-by: Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx>
> Reviewed-by: Janosch Frank <frankja@xxxxxxxxxxxxx>
>> arch/s390/kvm/gaccess.c | 122 +++++++++++++++++++++++-----------------
>> 1 file changed, 69 insertions(+), 53 deletions(-)
>> diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
>> index 0d11cea92603..7725dd7566ed 100644
>> --- a/arch/s390/kvm/gaccess.c
>> +++ b/arch/s390/kvm/gaccess.c
>> @@ -794,35 +794,74 @@ static int low_address_protection_enabled(struct kvm_vcpu *vcpu,
>> return 1;
>> -static int guest_page_range(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
>> - unsigned long *pages, unsigned long nr_pages,
>> - const union asce asce, enum gacc_mode mode)
>> + * guest_range_to_gpas() - Calculate guest physical addresses of page fragments
>> + * covering a logical range
> I'd add an empty line here.
The guide says not to.
> Function parameters
> Each function argument should be described in order,immediately following the short function description. Do not leave a blank line between the function description and the arguments, nor between the arguments.
In this case it's a static function, so not a must,
but I'll stick to it anyway.
> Apart from that this is a very nice cleanup.
>>> + * @vcpu: virtual cpu
>> + * @ga: guest address, start of range
>> + * @ar: access register
>> + * @gpas: output argument, may be NULL
>> + * @len: length of range in bytes
>> + * @asce: address-space-control element to use for translation
>> + * @mode: access mode