From: David Hildenbrand <david@redhat.com>
To: "Collin L. Walling" <walling@linux.vnet.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
Cornelia Huck <cohuck@redhat.com>,
Janosch Frank <frankja@linux.vnet.ibm.com>
Subject: Re: [PATCH RFC 2/6] KVM: s390: provide only a single function for setting the tod
Date: Wed, 7 Feb 2018 22:42:55 +0100 [thread overview]
Message-ID: <ffb06039-ef6b-1fdb-eb45-3083d91707ad@redhat.com> (raw)
In-Reply-To: <58ec2151-e95d-1286-e2ab-a958e6afcd2d@linux.vnet.ibm.com>
>>
>> -void kvm_s390_set_tod_clock_ext(struct kvm *kvm,
>> - const struct kvm_s390_vm_tod_clock *gtod)
>> +void kvm_s390_set_tod_clock(struct kvm *kvm,
>> + const struct kvm_s390_vm_tod_clock *gtod)
> Nit: off by one space --------^
This looks fine in code, just a quirk in the visual representation of
the diff file.
[...]
>> /* implemented in kvm-s390.c */
>> -void kvm_s390_set_tod_clock_ext(struct kvm *kvm,
>> - const struct kvm_s390_vm_tod_clock *gtod);
>> -void kvm_s390_set_tod_clock(struct kvm *kvm, u64 tod);
>> +void kvm_s390_set_tod_clock(struct kvm *kvm,
>> + const struct kvm_s390_vm_tod_clock *gtod);
> Same nit here.
Dito.
>> long kvm_arch_fault_in_page(struct kvm_vcpu *vcpu, gpa_t gpa, int writable);
>> int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr);
>> int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr);
>> diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
>> index c4c4e157c036..33505c32c48a 100644
>> --- a/arch/s390/kvm/priv.c
>> +++ b/arch/s390/kvm/priv.c
>> @@ -85,9 +85,10 @@ int kvm_s390_handle_e3(struct kvm_vcpu *vcpu)
>> /* Handle SCK (SET CLOCK) interception */
>> static int handle_set_clock(struct kvm_vcpu *vcpu)
>> {
>> + struct kvm_s390_vm_tod_clock gtod = { 0 };
>> int rc;
>> u8 ar;
>> - u64 op2, val;
>> + u64 op2;
>>
>> vcpu->stat.instruction_sck++;
>>
>> @@ -97,12 +98,12 @@ static int handle_set_clock(struct kvm_vcpu *vcpu)
>> op2 = kvm_s390_get_base_disp_s(vcpu, &ar);
>> if (op2 & 7) /* Operand must be on a doubleword boundary */
>> return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
>> - rc = read_guest(vcpu, op2, ar, &val, sizeof(val));
>> + rc = read_guest(vcpu, op2, ar, >od.tod, sizeof(gtod.tod));
>> if (rc)
>> return kvm_s390_inject_prog_cond(vcpu, rc);
>>
>> - VCPU_EVENT(vcpu, 3, "SCK: setting guest TOD to 0x%llx", val);
>> - kvm_s390_set_tod_clock(vcpu->kvm, val);
>> + VCPU_EVENT(vcpu, 3, "SCK: setting guest TOD to 0x%llx", gtod.tod);
>> + kvm_s390_set_tod_clock(vcpu->kvm, >od);
>>
>> kvm_s390_set_psw_cc(vcpu, 0);
>> return 0;
> Set clock only concerns the left-most 64 bits of the TOD-Clock, right?
> (thinking out
> loud) I wonder if we need to also concern ourselves about the epoch
> extension... but
> perhaps current use cases of set clock do not warrant that?
SET CLOCK will always set the right-most 64 bits of the TOD. The
left-most bits are assumed to be 0 (that's how I understand the
architecture). SET CLOCK can at one point no longer be reliably used.
But until these years come, SET CLOCK has to continue to work (even if
the guest has Multiple-epoch facility). And that can be guaranteed by
setting the epoch index accordingly.
Especially, if we have with mepoch: "Guest TOD = HOST TOD - 1", the
epoch index has to be set to 0xff and the epoch to 0xffff...fff. Right
now, the epoch index would not be set.
Should be easy to reproduced by doing a
STORE CLOCK %d followed by A SET_CLOCK %d in the guest. As the Host TOD
has been incremented, we have "Guest TOD = Host TOD - X", and not
setting the epoch index to 0xff results in a wrong Guest TOD calculation
on the next STORE CLOCK.
Thanks!
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2018-02-07 21:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 11:46 [PATCH RFC 0/6] KVM: s390: Multiple-epoch facility fixes David Hildenbrand
2018-02-07 11:46 ` [PATCH RFC 1/6] KVM: s390: take care of clock-comparator sign control David Hildenbrand
2018-02-07 13:47 ` Collin L. Walling
2018-02-07 13:58 ` David Hildenbrand
2018-02-07 14:06 ` Christian Borntraeger
2018-02-16 9:45 ` Christian Borntraeger
2018-02-07 11:46 ` [PATCH RFC 2/6] KVM: s390: provide only a single function for setting the tod David Hildenbrand
2018-02-07 20:13 ` Collin L. Walling
2018-02-07 20:15 ` Collin L. Walling
2018-02-07 21:42 ` David Hildenbrand [this message]
2018-02-07 11:46 ` [PATCH RFC 3/6] KVM: s390: consider epoch index on hotplugged CPUs David Hildenbrand
2018-02-15 13:09 ` Cornelia Huck
2018-02-16 9:50 ` Christian Borntraeger
2018-02-07 11:46 ` [PATCH RFC 4/6] KVM: s390: consider epoch index on TOD clock syncs David Hildenbrand
2018-02-07 20:08 ` Collin L. Walling
2018-02-07 21:35 ` David Hildenbrand
2018-02-07 22:43 ` Collin L. Walling
2018-02-08 12:15 ` David Hildenbrand
2018-02-07 11:46 ` [PATCH RFC 5/6] KVM: s390: no need to inititalize kvm->arch members to 0 David Hildenbrand
2018-02-15 13:25 ` Cornelia Huck
2018-02-07 11:46 ` [PATCH RFC 6/6] KVM: s390: generalize kvm_s390_get_tod_clock_ext() David Hildenbrand
2018-02-15 14:08 ` Cornelia Huck
2018-02-15 14:14 ` David Hildenbrand
2018-02-15 14:17 ` Cornelia Huck
2018-02-15 14:25 ` David Hildenbrand
2018-02-07 11:50 ` [PATCH RFC 0/6] KVM: s390: Multiple-epoch facility fixes David Hildenbrand
[not found] <b51c6b10-c0c0-2dae-3d74-7c21820d28ce@redhat.com>
2018-02-20 19:06 ` [PATCH RFC 2/6] KVM: s390: provide only a single function for setting the tod Christian Borntraeger
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=ffb06039-ef6b-1fdb-eb45-3083d91707ad@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@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;
as well as URLs for NNTP newsgroup(s).