From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Huth Date: Fri, 18 Mar 2016 10:34:21 +0000 Subject: Re: [kvm-unit-tests PATCH 4/5] powerpc: check lswx Message-Id: <56EBD9AD.6030800@redhat.com> List-Id: References: <1458141183-27207-1-git-send-email-lvivier@redhat.com> <1458141183-27207-5-git-send-email-lvivier@redhat.com> <56EBC5D8.6050901@redhat.com> <56EBD1F5.2070604@redhat.com> <56EBD323.7000808@redhat.com> <56EBD5E3.80606@redhat.com> In-Reply-To: <56EBD5E3.80606@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Laurent Vivier , kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: drjones@redhat.com, dgibson@redhat.com, pbonzini@redhat.com On 18.03.2016 11:18, Laurent Vivier wrote: > > > On 18/03/2016 11:06, Thomas Huth wrote: >> On 18.03.2016 11:01, Laurent Vivier wrote: > ... >>>>> + /* doc says it is invalid, real proc stops when it comes to >>>>> + * overwrite the register. >>>>> + * In all the cases, the register must stay untouched >>>>> + */ >>>>> + report("Don't overwrite Rb", regs[1] = (uint64_t)addr); >>>> >>>> Huh, how can this KVM unit test ever finish successfully if real >>>> processor stops? Should this last test maybe be optional and only be >>>> triggered if this kvm-unit-test is run with certain parameters? >>> >>> Well, my bad, I've not been accurate: the processor doesn't stop, but >>> the processing of the instruction is stopped. Only registers until Rb >>> (not included) are updated, and then the processor continue with the >>> next instruction. So we have just to test Rb is not modified. I'll >>> update the comment. >> >> Ok, now I've got it, I think. Maybe you should also check the >> "is_invalid" variable here? And it would also be interesting to see >> whether regs[0] (i.e. r31) has been changed or not? > > In fact, I've tested this with kvm PR and HV, on POWER8 and ppc970, and > there is never an illegal exception. It's why I don't check that. > > Checking regs[1] is correct in the case of the doc (illegal instruction) > and of the real processor (it doesn't update it). > > Checking regs[0] can be tricky: in the case of the doc (illegal) it > should not be updated, in the case of the real processor it is updated. > > I'd like this test checks only if TCG behaves like a real processor, > it's why I prefer to check this result against the result of a real > processor than against the result described in the doc. Ah, ok ... I just saw that there is even a comment in the QEMU sources about this in front of the helper_lswx() function ... then better keep the unit test code in its current shape! Thomas