From patchwork Mon Jul 2 16:05:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 938024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bklPN9Mo"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KBvx1Bs2z9s2R for ; Tue, 3 Jul 2018 02:06:53 +1000 (AEST) Received: from localhost ([::1]:33976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa1Lm-0004nh-Pd for incoming@patchwork.ozlabs.org; Mon, 02 Jul 2018 12:06:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa1L3-0004kc-Og for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:06:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa1Ky-0005Tu-CG for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:06:05 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa1Ky-0005TO-6J for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:06:00 -0400 Received: by mail-pg0-x230.google.com with SMTP id n15-v6so4107458pgv.4 for ; Mon, 02 Jul 2018 09:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EDg7+xQrWVFN2B7aGOJKgtLDfQ0mJ1smJERcqBGPq1Y=; b=bklPN9Mo1esbQfs5g1uySsYWn5iG7sSE/cyH6o3z1rQrTzIpqZMMMUq31BmrKYSFWH RjAyJpX5s0/t+UvELYAZEbwfkpMOyP/+gGqRLVbUi4HB+IzpJdG/fOrCmz6SOG+zhJSK T6U9i8AGBP8rKir9wl1PGdNfjC3PAkvsM0kd0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EDg7+xQrWVFN2B7aGOJKgtLDfQ0mJ1smJERcqBGPq1Y=; b=DIZlahop0yJTvUwdW3u4m8Npd8oJMGYWIwS+4YOvQpkqghPpfeSyYC4ZTHUVPvjw+u 3VnGqRAotuDLThSaHJJFV3GzBNTgYZSi9igjDxVTfOyxRpU8jQ3z7BFETcKGrUpcsbvR Ax+h8HtVG3uKVI3gR9aIuaYhfYvTrAA4PncqpdSAOhQRuGtr61E3ITSRWTWEBJRjgU8M hOWmq8oUeno/ztmVFcwHIuNkiAp7YWKdgk/zH+EFeN39gKx2x9pmMeQMGJ18iRGMY8or PwGo4lEId0GwZnZ9+IQyfNoXt9yS3QXWEDbDo2m+FkXNIF8mHD+K7RiuphyQxF4sgPeK fnSg== X-Gm-Message-State: APt69E3ebXTWikB8HBT7c4URruJRGNAoohNhRqlD6uqNVyDyTktXBeZR NwmVxAESGTO0vBwIBttO1edhR/qDkeE= X-Google-Smtp-Source: ADUXVKL2mEoPbzmjb+tUZH/quuleuuM1KYT3VoeGoFPXlYi7DQKtmKTyvZ+V4dXsITOSOBgRj3rqTQ== X-Received: by 2002:a63:6004:: with SMTP id u4-v6mr22162315pgb.441.1530547559032; Mon, 02 Jul 2018 09:05:59 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id e17-v6sm38107002pfd.15.2018.07.02.09.05.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 09:05:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 2 Jul 2018 09:05:46 -0700 Message-Id: <20180702160546.31969-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180702160546.31969-1-richard.henderson@linaro.org> References: <20180702160546.31969-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::230 Subject: [Qemu-devel] [PULL 6/6] cpu: Assert asidx_from_attrs return value in range X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/qom/cpu.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index cce2fd6acc..bd796579ee 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -620,11 +620,13 @@ static inline hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr) static inline int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs) { CPUClass *cc = CPU_GET_CLASS(cpu); + int ret = 0; if (cc->asidx_from_attrs) { - return cc->asidx_from_attrs(cpu, attrs); + ret = cc->asidx_from_attrs(cpu, attrs); + assert(ret < cpu->num_ases && ret >= 0); } - return 0; + return ret; } #endif