public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: David Hildenbrand <david@redhat.com>,
	linux-s390@vger.kernel.org, kvm@vger.kernel.org
Cc: Cornelia Huck <cohuck@redhat.com>,
	Janosch Frank <frankja@linux.vnet.ibm.com>,
	"Collin L. Walling" <walling@linux.vnet.ibm.com>
Subject: Re: [PATCH v2] KVM: s390: take care of clock-comparator sign control
Date: Mon, 5 Feb 2018 14:22:05 +0100	[thread overview]
Message-ID: <45ac154a-7352-40e5-2ed7-9f4ccc1cb9d5@de.ibm.com> (raw)
In-Reply-To: <7eba1a30-7881-0b05-3ab0-8fe5fe17a088@de.ibm.com>

Really adding Collin...


On 02/05/2018 01:46 PM, Christian Borntraeger wrote:
> Adding Collin. 
> 
> On 02/05/2018 11:40 AM, David Hildenbrand wrote:
>> Missed when enabling the Multiple-epoch facility. If the facility is
>> installed and the control is set, a sign based comaprison has to be
>> performed.
>>
>> Right now we would inject wrong interrupts and ignore interrupt
>> conditions. Also the sleep time is calculated in a wrong way.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>
>> We might be able to drop the checks for "test_kvm_facility(vcpu->kvm, 139)",
>> as the architecture states:
>>
>> "When the multiple-epoch facility is not installed in the configuration
>> and the clock-comparator sign control is one, it is unpredictable whether
>> the comparison follows the rules of unsigned or signed binary arithmetic."
>>
>> Have no machine to test this with :(
> 
> It will be somewhat hard to test anyway since the compare only differs for the
> case where one value (TOD or CKC) is before the 2042 date and the other one is
> after. have to think about a good test without needing an LPAR that is close
> to the wraparound.
> 
>>
>>  arch/s390/kvm/interrupt.c | 32 ++++++++++++++++++++++++++------
>>  1 file changed, 26 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
>> index 024ad8bcc516..6566a853c0b8 100644
>> --- a/arch/s390/kvm/interrupt.c
>> +++ b/arch/s390/kvm/interrupt.c
>> @@ -170,7 +170,16 @@ static int ckc_interrupts_enabled(struct kvm_vcpu *vcpu)
>>
>>  static int ckc_irq_pending(struct kvm_vcpu *vcpu)
>>  {
>> -	if (vcpu->arch.sie_block->ckc >= kvm_s390_get_tod_clock_fast(vcpu->kvm))
>> +	int64_t ckc, tod;
>> +
>> +	if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul &&
>> +	    test_kvm_facility(vcpu->kvm, 139)) {
>> +		ckc = vcpu->arch.sie_block->ckc;
>> +		tod = kvm_s390_get_tod_clock_fast(vcpu->kvm);
>> +		if (ckc >= tod)
>> +			return 0;
>> +	} else if (vcpu->arch.sie_block->ckc >=
>> +		   kvm_s390_get_tod_clock_fast(vcpu->kvm))
>>  		return 0;
> 
> Instead of changing the compare depending on another compare, maybe adding
> 0x8000000000000000 to the unsigned values makes the change easier to grasp. 
> On the other hand your code is closer to POP.
> 

  reply	other threads:[~2018-02-05 13:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 10:40 [PATCH v2] KVM: s390: take care of clock-comparator sign control David Hildenbrand
2018-02-05 12:46 ` Christian Borntraeger
2018-02-05 13:22   ` Christian Borntraeger [this message]
2018-02-05 13:49   ` David Hildenbrand
2018-02-06 16:34 ` Collin L. Walling
2018-02-06 17:02   ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45ac154a-7352-40e5-2ed7-9f4ccc1cb9d5@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=walling@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox