From patchwork Mon Aug 23 06:47:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 123391 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7N6nK7J007667 for ; Mon, 23 Aug 2010 06:49:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753362Ab0HWGtN (ORCPT ); Mon, 23 Aug 2010 02:49:13 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:55335 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751978Ab0HWGtM (ORCPT ); Mon, 23 Aug 2010 02:49:12 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 9EAC8170124; Mon, 23 Aug 2010 14:49:05 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o7N6jknJ026140; Mon, 23 Aug 2010 14:45:48 +0800 Received: from [10.167.141.76] (unknown [10.167.141.76]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 267C014C021; Mon, 23 Aug 2010 14:50:12 +0800 (CST) Message-ID: <4C72197E.7040408@cn.fujitsu.com> Date: Mon, 23 Aug 2010 14:47:26 +0800 From: Wei Yongjun User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100528 Thunderbird/3.0.5 MIME-Version: 1.0 To: Avi Kivity CC: kvm@vger.kernel.org Subject: [PATCH] Add realmode test for LDS/LES/LFS/LGS/LSS instruction References: <4C6BA1D4.5040503@cn.fujitsu.com> <4C6DF3CA.80709@cn.fujitsu.com> <4C70F3D7.3000407@redhat.com> In-Reply-To: <4C70F3D7.3000407@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 23 Aug 2010 06:49:21 +0000 (UTC) diff --git a/x86/realmode.c b/x86/realmode.c index b69e474..8c771fc 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1184,6 +1184,64 @@ void test_cwd_cdq() outregs.eax == 0x10000000 && outregs.edx == 0); } +static struct { + void *address; + unsigned short sel; +} __attribute__((packed)) desc = { + (void *)0x1234, + 0x10, +}; + +void test_lds_lss() +{ + inregs = (struct regs){ .ebx = (unsigned long)&desc }; + + MK_INSN(lds, "push %ds\n\t" + "lds (%ebx), %eax\n\t" + "mov %ds, %ebx\n\t" + "pop %ds\n\t"); + exec_in_big_real_mode(&insn_lds); + report("lds", R_AX | R_BX, + outregs.eax == (unsigned long)desc.address && + outregs.ebx == desc.sel); + + MK_INSN(les, "push %es\n\t" + "les (%ebx), %eax\n\t" + "mov %es, %ebx\n\t" + "pop %es\n\t"); + exec_in_big_real_mode(&insn_les); + report("les", R_AX | R_BX, + outregs.eax == (unsigned long)desc.address && + outregs.ebx == desc.sel); + + MK_INSN(lfs, "push %fs\n\t" + "lfs (%ebx), %eax\n\t" + "mov %fs, %ebx\n\t" + "pop %fs\n\t"); + exec_in_big_real_mode(&insn_lfs); + report("lfs", R_AX | R_BX, + outregs.eax == (unsigned long)desc.address && + outregs.ebx == desc.sel); + + MK_INSN(lgs, "push %gs\n\t" + "lgs (%ebx), %eax\n\t" + "mov %gs, %ebx\n\t" + "pop %gs\n\t"); + exec_in_big_real_mode(&insn_lgs); + report("lgs", R_AX | R_BX, + outregs.eax == (unsigned long)desc.address && + outregs.ebx == desc.sel); + + MK_INSN(lss, "push %ss\n\t" + "lss (%ebx), %eax\n\t" + "mov %ss, %ebx\n\t" + "pop %ss\n\t"); + exec_in_big_real_mode(&insn_lss); + report("lss", R_AX | R_BX, + outregs.eax == (unsigned long)desc.address && + outregs.ebx == desc.sel); +} + void realmode_start(void) { test_null(); @@ -1215,6 +1273,7 @@ void realmode_start(void) test_cbw(); test_cwd_cdq(); test_das(); + test_lds_lss(); exit(0); }