diff options
author | Peter Crosthwaite <peter.crosthwaite@xilinx.com> | 2013-11-27 20:27:33 -0800 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-12-24 17:27:17 +0100 |
commit | 0ab4c94c844cb3953adedbd27adc378b3cf31d9e (patch) | |
tree | a4755b0c34aa6f7bc3c97ae673e7ac2f82e24e4c /include | |
parent | c272758f93b9c88c884461a2baa37b8f4008bf02 (diff) | |
download | qemu-0ab4c94c844cb3953adedbd27adc378b3cf31d9e.zip qemu-0ab4c94c844cb3953adedbd27adc378b3cf31d9e.tar.gz qemu-0ab4c94c844cb3953adedbd27adc378b3cf31d9e.tar.bz2 |
qom: Split out object and class caches
The object-cast and class-cast caches cannot be shared because class
caching is conditional on the target type not being an interface and
object caching is unconditional. Leads to a bug when a class cast
to an interface follows an object cast to the same interface type:
FooObject = FOO(obj);
FooClass = FOO_GET_CLASS(obj);
Where TYPE_FOO is an interface. The first (object) cast will be
successful and cache the casting result (i.e. TYPE_FOO will be cached).
The second (class) cast will then check the shared cast cache
and register a hit. The issue is, when a class cast hits in the cache
it just returns a pointer cast of the input class (i.e. the concrete
class).
When casting to an interface, the cast itself must return the
interface class, not the concrete class. The implementation of class
cast caching already ensures that the returned cast result is only
a pointer cast before caching. The object cast logic however does
not have this check.
Resolve by just splitting the object and class caches.
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Nathan Rossi <nathan.rossi@xilinx.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/qom/object.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/qom/object.h b/include/qom/object.h index a275db2..5f78847 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -358,7 +358,8 @@ struct ObjectClass Type type; GSList *interfaces; - const char *cast_cache[OBJECT_CLASS_CAST_CACHE]; + const char *object_cast_cache[OBJECT_CLASS_CAST_CACHE]; + const char *class_cast_cache[OBJECT_CLASS_CAST_CACHE]; ObjectUnparent *unparent; }; |