From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJmNs-0006Lr-5t for qemu-devel@nongnu.org; Tue, 10 May 2011 08:49:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QJmNq-000524-Ri for qemu-devel@nongnu.org; Tue, 10 May 2011 08:49:52 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:40799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJmNq-00051r-KT for qemu-devel@nongnu.org; Tue, 10 May 2011 08:49:50 -0400 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p4ACnn9e002879 for ; Tue, 10 May 2011 12:49:49 GMT Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4ACnnI61703956 for ; Tue, 10 May 2011 13:49:49 +0100 Received: from d06av08.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4ACnm2t002575 for ; Tue, 10 May 2011 13:49:48 +0100 Message-ID: <4DC9346B.9050309@de.ibm.com> Date: Tue, 10 May 2011 14:49:47 +0200 From: Christian Borntraeger MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] s390x: fix memory detection for guests > 64GB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Carsten Otte , "qemu-devel@nongnu.org" Alex, the s390 memory detection has a 16bit field that specifies the amount of increments. This patch adopts the memory size to always fit into that scheme. This also fixes virtio detection for these guests, since the descriptor page is located after the main memory. Signed-off-by: Christian Borntraeger --- a/target-s390x/op_helper.c +++ b/target-s390x/op_helper.c @@ -2361,6 +2361,7 @@ static void ext_interrupt(CPUState *env, int type, uint32_t param, int sclp_service_call(CPUState *env, uint32_t sccb, uint64_t code) { int r = 0; + int shift = 0; #ifdef DEBUG_HELPER printf("sclp(0x%x, 0x%" PRIx64 ")\n", sccb, code); @@ -2375,8 +2376,10 @@ int sclp_service_call(CPUState *env, uint32_t sccb, uint64_t code) switch(code) { case SCLP_CMDW_READ_SCP_INFO: case SCLP_CMDW_READ_SCP_INFO_FORCED: - stw_phys(sccb + SCP_MEM_CODE, ram_size >> 20); - stb_phys(sccb + SCP_INCREMENT, 1); + while ((ram_size >> (20 + shift)) > 65535) + shift++; + stw_phys(sccb + SCP_MEM_CODE, ram_size >> (20 + shift)); + stb_phys(sccb + SCP_INCREMENT, 1 << shift); stw_phys(sccb + SCP_RESPONSE_CODE, 0x10); if (kvm_enabled()) { diff --git a/vl.c b/vl.c index 68c3b53..7b4adff 100644 --- a/vl.c +++ b/vl.c @@ -2962,6 +2962,16 @@ int main(int argc, char **argv, char **envp) if (ram_size == 0) ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; + /* s390x ram size detection needs a 16bit multiplier + an increment. So + guests > 64GB can be specified in 2MB steps etc */ + if (strstr(machine->name, "s390")) { + int shift = 0; + + while ((ram_size >> (20 + shift)) > 65535) + shift++; + ram_size = ram_size >> (20 + shift) << (20 + shift); + } + /* init the dynamic translator */ cpu_exec_init_all(tb_size * 1024 * 1024);